This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] print error message if (auto) disassembly failed


> OK, but your suggested message text is too long, I think.  Something
> shorter, like "(address unreadable)" is better, IMO.

Frankly, I think this is overkill - even with the 64bit addresses
the line was still less than 70 characters long. But I'm not going
to argue. Here you go:

    (gdb) core core
    warning: core file may not match specified executable file.
    Core was generated by `./crash'.
    Program terminated with signal 6, Aborted.
    #0  0x00007fe6fe543307 in ?? ()
    0x00007fe6fe543307:     (cannot read memory)

2009-04-17  Joel Brobecker  <brobecker@adacore.com>

        * stack.c (do_gdb_disassembly): Print an error message if an error
        was thrown while trying to perform the disassembly.

I'm currently testing this patch on x86_64-linux, but I don't really
expect any problem.

-- 
Joel
commit de33df66fc64edf55aa81a7d08adccf911aa4fdf
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Tue Apr 14 15:23:25 2009 -0700

        * stack.c (do_gdb_disassembly): Print an error message if an error
        was thrown while trying to perform the disassembly.

diff --git a/gdb/stack.c b/gdb/stack.c
index dfe3900..bbeff2c 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -507,6 +507,21 @@ do_gdb_disassembly (int how_many, CORE_ADDR low, CORE_ADDR high)
     {
       gdb_disassembly_stub (&args);
     }
+  /* If an exception was thrown while doing the disassembly, print
+     the error message, to give the user a clue of what happened.  */
+  if (exception.reason == RETURN_ERROR)
+    {
+      if (exception.error == MEMORY_ERROR)
+	{
+	  /* For memory errors, prefer a short error message over
+	     the error message provided in the exception.  */
+	  gdb_flush (gdb_stdout);
+	  gdb_flush (gdb_stderr);
+	  fprintf_filtered (gdb_stderr, _("(cannot read memory)\n"));
+	}
+      else
+	exception_print (gdb_stderr, exception);
+    }
 }
 
 /* Print information about frame FRAME.  The output is format according

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]