From: Frederic RISS <frederic.riss@st.com>
To: gdb@sourceware.org
Subject: Robustify frame_unwind_address_in_block heuristic?
Date: Wed, 01 Oct 2008 14:42:00 -0000 [thread overview]
Message-ID: <1222872102.6785.516.camel@crx3051.cro.st.com> (raw)
Hi,
frame_unwind_address_in_block contains the following code:
/* If THIS frame is not inner most (i.e., NEXT isn't the sentinel),
and NEXT is `normal' (i.e., not a sigtramp, dummy, ....) THIS
frame's PC ends up pointing at the instruction fallowing the
"call". Adjust that PC value so that it falls on the call
instruction (which, hopefully, falls within THIS frame's code
block). So far it's proved to be a very good approximation. See
get_frame_type() for why ->type can't be used. */
if (next_frame->level >= 0
&& get_frame_type (next_frame) == NORMAL_FRAME)
--pc;
and indeed, this has proved to be a very good and useful approximation.
However, I'm facing a little issue with this. I've developed a custom
frame unwinder for some project. It unwinds over some asm stubs which do
branch to regular C code, but which also set the link register
(containing the return address) to the entry of some other asm that
finishes the stub's work (let's call that ret_stub).
During a debug session, the dwarf2 unwinder finds the ret_stub return
address and my custom unwinder kicks in to unwind to the following
frame... which all seems right except for one little glitch: when
printing the ret_stub frame, the above heuristic decrements the return
address and points to a symbol that has no other relevance in the
backtrace than being the one that happens to be linked just before
ret_stub. Quite confusing for the user.
I have to admit that the above is a convoluted case which shouldn't show
up in a 'standard' debug session. It's also not the first time I wish
that frame unwinders were more flexible/modular, but it's the first time
that I wasn't able to work around the issue without patching GDB's core
functionality. Would it be acceptable to add a check to the above
function that checks whether pc-1 points into the same function as pc?
Or maybe someone sees another way to prevent that issue?
Thanks,
Fred.
next reply other threads:[~2008-10-01 14:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-01 14:42 Frederic RISS [this message]
2008-10-01 14:48 ` Daniel Jacobowitz
2008-10-01 15:26 ` Frederic RISS
2008-10-01 15:29 ` Joel Brobecker
2008-10-01 15:58 ` Frederic RISS
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=1222872102.6785.516.camel@crx3051.cro.st.com \
--to=frederic.riss@st.com \
--cc=gdb@sourceware.org \
/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