From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3741 invoked by alias); 16 Apr 2009 17:39:33 -0000 Received: (qmail 3721 invoked by uid 22791); 16 Apr 2009 17:39:30 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Apr 2009 17:39:24 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A32442BAC59 for ; Thu, 16 Apr 2009 13:39:22 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EknO11SG9Kkc for ; Thu, 16 Apr 2009 13:39:22 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 6AA1C2BAC58 for ; Thu, 16 Apr 2009 13:39:22 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 6EEE9F58C1; Thu, 16 Apr 2009 10:39:18 -0700 (PDT) Date: Thu, 16 Apr 2009 17:39:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA] print error message if (auto) disassembly failed Message-ID: <20090416173918.GP7557@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="llIrKcgUOe3dCx0c" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00371.txt.bz2 --llIrKcgUOe3dCx0c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1665 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 * 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 --llIrKcgUOe3dCx0c Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="disass.diff" Content-length: 822 commit 056d77e1b180988399b18ea5d109813dbd934da8 Author: Joel Brobecker 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 --llIrKcgUOe3dCx0c--