summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2012-07-27 17:24:31 +0000
committerPedro Alves <palves@redhat.com>2012-07-27 17:24:31 +0000
commit84552b164d4b5dc25334566f68f2b8aca72c8db0 (patch)
tree87690d989ac25c3c918f1f42015e2df7ece32e2d /gdb
parentc4dd807e7bd468289a05d8af2d6cde45d727893b (diff)
downloadbinutils-gdb-84552b164d4b5dc25334566f68f2b8aca72c8db0.tar.gz
2012-07-27 Roland Schwingel <roland.schwingel@onevision.com>
* amd64-windows-tdep.c: Include "frame.h". (amd64_windows_skip_trampoline_code): New function. (amd64_windows_init_abi): Add trampoline registration.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/amd64-windows-tdep.c37
2 files changed, 43 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e6f96273f65..0ba1827eed1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2012-07-27 Roland Schwingel <roland.schwingel@onevision.com>
+
+ * amd64-windows-tdep.c: Include "frame.h".
+ (amd64_windows_skip_trampoline_code): New function.
+ (amd64_windows_init_abi): Add trampoline registration.
+
2012-07-27 Yao Qi <yao@codesourcery.com>
* tracepoint.c (cur_traceframe_number): Remove.
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 41e0efa4e76..528fbb6107b 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -24,6 +24,7 @@
#include "gdbcore.h"
#include "regcache.h"
#include "windows-tdep.h"
+#include "frame.h"
/* The registers used to pass integer arguments during a function call. */
static int amd64_windows_dummy_call_integer_regs[] =
@@ -154,6 +155,40 @@ amd64_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
return pc;
}
+/* Check Win64 DLL jmp trampolines and find jump destination. */
+
+static CORE_ADDR
+amd64_windows_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
+{
+ CORE_ADDR destination = 0;
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+ /* Check for jmp *<offset>(%rip) (jump near, absolute indirect (/4)). */
+ if (pc && read_memory_unsigned_integer (pc, 2, byte_order) == 0x25ff)
+ {
+ /* Get opcode offset and see if we can find a reference in our data. */
+ ULONGEST offset
+ = read_memory_unsigned_integer (pc + 2, 4, byte_order);
+
+ /* Get address of function pointer at end of pc. */
+ CORE_ADDR indirect_addr = pc + offset + 6;
+
+ struct minimal_symbol *indsym
+ = indirect_addr ? lookup_minimal_symbol_by_pc (indirect_addr) : NULL;
+ const char *symname = indsym ? SYMBOL_LINKAGE_NAME (indsym) : NULL;
+
+ if (symname)
+ {
+ if (strncmp (symname, "__imp_", 6) == 0
+ || strncmp (symname, "_imp_", 5) == 0)
+ destination
+ = read_memory_unsigned_integer (indirect_addr, 8, byte_order);
+ }
+ }
+
+ return destination;
+}
static void
amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -174,6 +209,8 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->integer_param_regs_saved_in_caller_frame = 1;
set_gdbarch_return_value (gdbarch, amd64_windows_return_value);
set_gdbarch_skip_main_prologue (gdbarch, amd64_skip_main_prologue);
+ set_gdbarch_skip_trampoline_code (gdbarch,
+ amd64_windows_skip_trampoline_code);
set_gdbarch_iterate_over_objfiles_in_search_order
(gdbarch, windows_iterate_over_objfiles_in_search_order);