Re: RFC: %ebp-based backtrace patch

Daniel Jacobowitz
2009-12-27T22:03:22Z

On Sun, Dec 27, 2009 at 10:37:19PM +0100, Mark Kettenis wrote:
> Sorry, but I don't see how this would solve things. Do you have a
> diff for me to look at?

Sure. Here's a version that passes signull.exp for me.

I also noticed that Ubuntu has a version of this applied to
amd64-tdep.c. I don't know if that has merit or not; I wouldn't
expect it to matter much, given that the ABI mandates .eh_frame.

--
Daniel Jacobowitz
CodeSourcery

2009-12-27 Michael Matz <matz@suse.de>
Daniel Jacobowitz <dan@codesourcery.com>

* i386-tdep.c (i386_frame_cache): Assume valid anonymous
functions use a frame pointer.

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.290
diff -u -p -r1.290 i386-tdep.c
--- i386-tdep.c 12 Oct 2009 15:52:28 -0000 1.290
+++ i386-tdep.c 27 Dec 2009 21:59:51 -0000
@@ -1394,12 +1394,24 @@ 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 != 0
+ || target_read_memory (get_frame_pc (this_frame), buf, 1))
{
+ /* We're in a known function, but did not find a frame
+ setup. Assume that the function does not use %ebp.
+ Alternatively, we may have jumped to an invalid
+ address; in that case there is definitely no new
+ frame in %ebp. */
get_frame_register (this_frame, I386_ESP_REGNUM, buf);
cache->base = extract_unsigned_integer (buf, 4, byte_order)
+ cache->sp_offset;
}
+ else
+ /* We're in an unknown function. We could not find the start
+ of the function to analyze the prologue; our best option is
+ to assume a typical frame layout with the caller's %ebp
+ saved. */
+ cache->saved_regs[I386_EBP_REGNUM] = 0;
}

/* Now that we have the base address for the stack frame we can