This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [SH][PATCH] Disable ABI frame sniffer
Andrew Stubbs wrote:
I could modify the sh sniffer such that it actually does something.
However, this would require modifying frame_unwind_find_by_frame() and
family such that it can accept a NULL answer from every sniffer.
This won't work. The whole unwinding mechanism is lazy and does not
happen until print_frame_info() has already committed to printing
something, it just doesn't know what yet.
The reason for this is that get_prev_frame() and get_prev_frame_1() have
already effectively promised that there will be another frame, but
haven't actually ventured to find out what it is - that is done lazily
as required.
It isn't possible to have the sniffer say 'I know this is the last frame
on the stack' because, unless the compiler says so, all it really could
tell is that this is the last frame as it knows it. It might work if the
code asked all the sniffers and returned 'end of stack' if all of them
fail to recognise a frame.
But, all is not lost ....
The attached patch to get_prev_frame_1() *does* fix the problem. With
this I get exactly what I want.
I have no doubt that it is somehow horribly flawed and totally
unacceptable, but hopefully something will emerge from all this.
BTW, the file has a comment that says 'Allocate the new frame but do not
wire it in to the frame chain', but then it appears to go ahead and wire
up the frame chain. Is this a mistake or am I just misunderstanding it?
Thanks
Andrew Stubbs
2005-11-24 Andrew Stubbs <andrew.stubbs@st.com>
* frame.c (get_prev_frame_1): Check the PC is within the program
before allowing the frame to be created.
Index: src/gdb/frame.c
===================================================================
--- src.orig/gdb/frame.c 2005-11-24 16:45:22.000000000 +0000
+++ src/gdb/frame.c 2005-11-24 17:24:09.000000000 +0000
@@ -1123,6 +1123,16 @@ get_prev_frame_1 (struct frame_info *thi
this_frame->prev = prev_frame;
prev_frame->next = this_frame;
+ /* Check that the new frame would refer to a location within the
+ program. This has to be done after it is linked in or the
+ function calls will not work. If the location is junk then
+ we have probably dropped off the bottom of the stack. */
+ if (!find_pc_section (frame_unwind_address_in_block (this_frame)))
+ {
+ this_frame->prev = NULL;
+ return NULL;
+ }
+
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "-> ");