This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH, ppc64] Fix stepping into calls via thunk
- From: Luis Machado <lgustavo at codesourcery dot com>
- To: "'gdb-patches at sourceware dot org'" <gdb-patches at sourceware dot org>
- Date: Tue, 04 Jun 2013 23:34:38 +0200
- Subject: [PATCH, ppc64] Fix stepping into calls via thunk
- Reply-to: lgustavo at codesourcery dot com
Hi,
And finally this is the last failure i was seeing for
gdb.cp/virtfunc.exp for ppc64.
The failure was related to not being able to step into a member function
call via a thunk, ppc64 would step over that call.
Thunk skipping is handled by logic in
gdb/gnu-v3-abi.c:gnuv3_skip_trampoline. We go from the address to a
thunk symbol to the real function symbol and then to its final address,
where GDB inserts a step-resume breakpoint.
For ppc64, though, what GDB thinks is the address of the real function
isn't really the address of the function, but a pointer to a function
descriptor. We need to fetch the real function's address from that
descriptor.
This patch does exactly that, and it is very simple.
The use of current_target made me scratch my head a little. I seem to
recall we dropped further uses of this variable in the past, but this
hook still seems to require the target_ops to be passed. Is this OK?
Thanks,
Luis
2013-06-04 Luis Machado <lgustavo@codesourcery.com>
* gdb/gnu-v3-abi.c (gnuv3_skip_trampoline): Handle thunk
minimal symbols pointing to function descriptors.
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 6812c1d..1821f18 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1207,7 +1207,7 @@ gnuv3_get_type_from_type_info (struct value *type_info_ptr)
static CORE_ADDR
gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc)
{
- CORE_ADDR real_stop_pc, method_stop_pc;
+ CORE_ADDR real_stop_pc, method_stop_pc, func_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
struct minimal_symbol *thunk_sym, *fn_sym;
struct obj_section *section;
@@ -1236,6 +1236,16 @@ gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc)
return 0;
method_stop_pc = SYMBOL_VALUE_ADDRESS (fn_sym);
+
+ /* Some targets have minimal symbols pointing to function descriptors
+ (powerpc 64 for example). Make sure to retrieve the address
+ of the real function from the function descriptor before passing on
+ the address to other layers of GDB. */
+ func_addr = gdbarch_convert_from_func_ptr_addr (gdbarch, method_stop_pc,
+ ¤t_target);
+ if (func_addr != 0)
+ method_stop_pc = func_addr;
+
real_stop_pc = gdbarch_skip_trampoline_code
(gdbarch, frame, method_stop_pc);
if (real_stop_pc == 0)