From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sourceware.org
Cc: Mark Kettenis <kettenis@gnu.org>, Michael Matz <matz@suse.de>
Subject: RFC: %ebp-based backtrace patch
Date: Mon, 06 Jul 2009 18:33:00 -0000 [thread overview]
Message-ID: <20090706183316.GA26074@caradoc.them.org> (raw)
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 <matz@suse.de>
* 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
next reply other threads:[~2009-07-06 18:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-06 18:33 Daniel Jacobowitz [this message]
2009-07-06 20:11 ` Frank Ch. Eigler
2009-07-06 20:21 ` Daniel Jacobowitz
2009-07-07 12:15 ` Michael Matz
2009-07-07 13:19 ` Frank Ch. Eigler
2009-07-07 13:49 ` Michael Matz
2009-07-06 21:57 ` Mark Kettenis
2009-07-07 12:00 ` Michael Matz
2009-07-07 13:00 ` Daniel Jacobowitz
2009-07-07 13:07 ` Mark Kettenis
2009-07-08 9:01 ` Mark Kettenis
2009-07-08 12:53 ` Daniel Jacobowitz
2009-12-27 16:59 ` Daniel Jacobowitz
2009-12-27 21:37 ` Mark Kettenis
2009-12-27 22:03 ` Daniel Jacobowitz
2010-02-01 19:46 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090706183316.GA26074@caradoc.them.org \
--to=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=kettenis@gnu.org \
--cc=matz@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox