aboutsummaryrefslogtreecommitdiff
path: root/gdb/amd64-windows-tdep.c
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2010-09-27 22:05:40 +0000
committerPierre Muller <muller@sourceware.org>2010-09-27 22:05:40 +0000
commit99e24b906565b6ba736dc535086373e7c246bfe0 (patch)
tree9abfe364f15d4d440e6d46d320a825143a4b54c7 /gdb/amd64-windows-tdep.c
parent6a44904e978701a0f9dd17bcfbbd2de07be14e89 (diff)
downloadgdb-99e24b906565b6ba736dc535086373e7c246bfe0.zip
gdb-99e24b906565b6ba736dc535086373e7c246bfe0.tar.gz
gdb-99e24b906565b6ba736dc535086373e7c246bfe0.tar.bz2
* amd64-windows-tdep.c (amd64_skip_main_prologue): New function.
(amd64_windows_init_abi): Register amd64_skip_main_prologue as gdbarch skip_main_prologue method.
Diffstat (limited to 'gdb/amd64-windows-tdep.c')
-rw-r--r--gdb/amd64-windows-tdep.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 05d0824..0a44562 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -122,6 +122,38 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct type *func_type,
}
}
+/* Check that the code pointed to by PC corresponds to a call to
+ __main, skip it if so. Return PC otherwise. */
+
+static CORE_ADDR
+amd64_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ gdb_byte op;
+
+ target_read_memory (pc, &op, 1);
+ if (op == 0xe8)
+ {
+ gdb_byte buf[4];
+
+ if (target_read_memory (pc + 1, buf, sizeof buf) == 0)
+ {
+ struct minimal_symbol *s;
+ CORE_ADDR call_dest;
+
+ call_dest = pc + 5 + extract_signed_integer (buf, 4, byte_order);
+ s = lookup_minimal_symbol_by_pc (call_dest);
+ if (s != NULL
+ && SYMBOL_LINKAGE_NAME (s) != NULL
+ && strcmp (SYMBOL_LINKAGE_NAME (s), "__main") == 0)
+ pc += 5;
+ }
+ }
+
+ return pc;
+}
+
+
static void
amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
@@ -140,6 +172,7 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->memory_args_by_pointer = 1;
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_solib_ops (gdbarch, &solib_target_so_ops);
}