Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] print error message if (auto) disassembly failed
@ 2009-04-16 17:39 Joel Brobecker
  2009-04-16 17:52 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Joel Brobecker @ 2009-04-16 17:39 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

I noticed this by accident after we introduced the new feature where
the debugger prints the assembly of the next line each time we stop.
Basically, I loaded the wrong core file and got:

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

As you can see, GDB tried to print the instruction at the address
where the core file says the program stopped, but instead printed
nothing. This has two consequences:

  1. The user does not really know what the problem was;
  2. A testsuite driver that relies on seeing the prompt being placed
     at the beginning of the line would wait indefinitely for the prompt
     to come back.

I propose to change the behavior to print the error message:

        (gdb) core core
        warning: core file may not match specified executable file.
        Core was generated by `./crash'.
        Program terminated with signal 6, Aborted.
        #0  0x00007f8befcc8307 in ?? ()
        0x00007f8befcc8307:     Cannot access memory at address 0x7f8befcc8307
        (gdb) 

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

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

Tested on x86_64-linux. Any objections?

(FWIW: I did not realize that GDB would now print the current assembly
 instruction by default when the change came in. I don't think that's
 a useful default based on my own usage, but no big deal)

-- 
Joel

[-- Attachment #2: disass.diff --]
[-- Type: text/x-diff, Size: 822 bytes --]

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

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

diff --git a/gdb/stack.c b/gdb/stack.c
index dfe3900..956aaa0 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -507,6 +507,10 @@ 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)
+    exception_print (gdb_stderr, exception);
 }
 
 /* Print information about frame FRAME.  The output is format according

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2009-04-23 18:49 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16 17:39 [RFA] print error message if (auto) disassembly failed Joel Brobecker
2009-04-16 17:52 ` Eli Zaretskii
2009-04-16 18:02   ` Joel Brobecker
2009-04-16 18:16     ` Eli Zaretskii
2009-04-16 19:07       ` Joel Brobecker
2009-04-16 21:37         ` Eli Zaretskii
2009-04-16 21:54           ` Joel Brobecker
2009-04-16 22:09             ` Pedro Alves
2009-04-17  9:10             ` Eli Zaretskii
2009-04-16 23:57           ` Joel Brobecker
2009-04-17  7:33             ` Hui Zhu
2009-04-17  9:22             ` Eli Zaretskii
2009-04-17 15:50               ` Joel Brobecker
2009-04-17 17:34             ` Daniel Jacobowitz
2009-04-17 22:16               ` Joel Brobecker
2009-04-18  6:48                 ` Eli Zaretskii
2009-04-16 22:23 ` Tom Tromey
2009-04-16 23:59   ` Joel Brobecker
2009-04-17  5:33     ` Hui Zhu
2009-04-17 15:57       ` Joel Brobecker
2009-04-17 16:16         ` Tom Tromey
2009-04-17 16:59         ` Hui Zhu
2009-04-17  9:23     ` Eli Zaretskii
2009-04-17 10:05       ` Eli Zaretskii
2009-04-23 18:49 ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox