From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5599 invoked by alias); 22 Jan 2009 03:22:29 -0000 Received: (qmail 5590 invoked by uid 22791); 22 Jan 2009 03:22:28 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Jan 2009 03:22:24 +0000 Received: (qmail 8569 invoked from network); 22 Jan 2009 03:22:22 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Jan 2009 03:22:22 -0000 From: Pedro Alves To: gdb@sourceware.org Subject: hook-stop sees dummy frames, bug or feature? Date: Thu, 22 Jan 2009 03:22:00 -0000 User-Agent: KMail/1.9.10 Cc: vargaz@gmail.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200901220323.18225.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-01/txt/msg00150.txt.bz2 I was looking at fixing PR9664 , which was a regression I introduced here: http://sourceware.org/ml/gdb-patches/2008-09/msg00193.html The regression is about the fact that the hook-stop in normal_stop is now run after frame printing, while it is documented as being run before. "(@samp{hook-stop}) makes the associated commands execute every time execution stops in your program: before breakpoint commands are run, displays are printed, or the stack frame is printed." The current sequence is roughtly: normal_stop () { ... - print frame - save `return' or infcall registers - pop dummy frame - hook-stop ... } Clearly, I need to put running the hook-stop higher up again. In gdb <= 6.8, the hook-stop was run before we poped off the dummy frame: normal_stop () { ... - hook-stop - print frame - save `return' or infcall registers - pop dummy frame ... } The case I'm considering is this: (basically: define hook-stop frame end p func() ) >gdb-6.8 ./gdb (top-gdb) start Starting program: /home/pedro/gdb/normal_stop/build/gdb/gdb main (argc=1, argv=0x7ffff00043f8) at ../../src/gdb/gdb.c:28 28 memset (&args, 0, sizeof args); (top-gdb) define hook-stop Type commands for definition of "hook-stop". End with a line saying just "end". >frame >end (top-gdb) p malloc (0) #0 <<<<<< "frame" in hook-stop Current language: auto; currently asm $1 = 11407376 <<<<<< 'malloc (0)' result Current language: auto; currently c (top-gdb) frame <<<<<< "frame" again shows something else. #0 main (argc=1, argv=0x7ffff00043f8) at ../../src/gdb/gdb.c:28 28 memset (&args, 0, sizeof args); Is the fact that the dummy frame is visible in a hook-stop a bug, or a feature? This is the current mainline behaviour: (top-gdb) p malloc (0) #0 main (argc=1, argv=0x7fffffffe408) at ../../src/gdb/gdb.c:28 <<< "frame" in hook-stop. 28 memset (&args, 0, sizeof args); $1 = 11407440 (top-gdb) I'm inclined to consider it a bug to show the dummy frame, but I may be missing some use cases. Say, change normal_stop to: normal_stop () { ... - pop dummy frame - hook-stop - print frame - save `return' or infcall registers ... } (saving infcall registers could also move up, I think, but I'll leave that out for now) What do you guys think? -- Pedro Alves