From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29227 invoked by alias); 6 Jul 2009 18:33:28 -0000 Received: (qmail 29214 invoked by uid 22791); 6 Jul 2009 18:33:27 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Jul 2009 18:33:20 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id C3305108AF; Mon, 6 Jul 2009 18:33:18 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id 8315E104E1; Mon, 6 Jul 2009 18:33:18 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1MNt09-00074m-0F; Mon, 06 Jul 2009 14:33:17 -0400 Date: Mon, 06 Jul 2009 18:33:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Cc: Mark Kettenis , Michael Matz Subject: RFC: %ebp-based backtrace patch Message-ID: <20090706183316.GA26074@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org, Mark Kettenis , Michael Matz MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes 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-07/txt/msg00147.txt.bz2 A number of Linux distributions are carrying the attached patch from Michael Matz. Frankly, I don't understand i386 frame layout issues well enough to approve this; I'm posting this in hopes of starting a discussion between Mark Kettenis and Michael Matz. The patch does seem to help in practice. I took a 32-bit Debian system, with minimal packages installed, and ran bash inside GDB. I interrupted it while sitting at a prompt. Results without the patch: #0 0xf7fdf430 in __kernel_vsyscall () #1 0xf7f0ce93 in __read_nocancel () from /lib/i686/cmov/libc.so.6 #2 0x080cfca6 in rl_getc () #3 0x080d0103 in rl_read_key () #4 0x080be7d7 in readline_internal_char () #5 0x080bebc5 in readline () #6 0x080689d1 in ?? () #7 0x081b7808 in ?? () #8 0x080942c0 in ?? () #9 0xffffc5d8 in ?? () #10 0x08080e26 in notify_and_cleanup () #11 0x0806422b in ?? () #12 0x00000000 in ?? () With: #0 0xf7fdf430 in __kernel_vsyscall () #1 0xf7f0ce93 in __read_nocancel () from /lib/i686/cmov/libc.so.6 #2 0x080cfca6 in rl_getc () #3 0x080d0103 in rl_read_key () #4 0x080be7d7 in readline_internal_char () #5 0x080bebc5 in readline () #6 0x080689d1 in ?? () #7 0x0806422b in ?? () #8 0x08065492 in ?? () #9 0x08068f57 in yyparse () #10 0x08061c98 in parse_command () #11 0x08061d7f in read_command () #12 0x08061fc3 in reader_loop () #13 0x08061ae9 in main () Michael's explanation of the patch is over here: https://bugzilla.novell.com/show_bug.cgi?id=390722#c25 My understanding is that this only affects frames we can't find a symbol for. Instead of assuming the frame starts at %esp - 4 (since sp_offset is initialized to -4 and then not updated if we did not find a symbol to analyze), assume that it uses and saved %ebp. We have no reliable information at this point and the new heuristic seems to be right more often. Mark, could you comment on this patch? -- Daniel Jacobowitz CodeSourcery 2009-07-06 Michael Matz * i386-tdep.c (i386_frame_cache): Assume anonymous functions use a frame pointer. --- gdb/i386-tdep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Index: gdb-6.8.50.20090628/gdb/i386-tdep.c =================================================================== --- gdb-6.8.50.20090628.orig/gdb/i386-tdep.c 2009-07-05 20:38:47.000000000 -0400 +++ gdb-6.8.50.20090628/gdb/i386-tdep.c 2009-07-05 20:39:17.000000000 -0400 @@ -1377,11 +1377,13 @@ i386_frame_cache (struct frame_info *thi /* This will be added back below. */ cache->saved_regs[I386_EIP_REGNUM] -= cache->base; } - else + else if (cache->pc) { get_frame_register (this_frame, I386_ESP_REGNUM, buf); cache->base = extract_unsigned_integer (buf, 4) + cache->sp_offset; } + else + cache->saved_regs[I386_EBP_REGNUM] = 0; } /* Now that we have the base address for the stack frame we can