diff options
author | Pierre Muller <muller@ics.u-strasbg.fr> | 2008-06-11 22:03:49 +0000 |
---|---|---|
committer | Pierre Muller <muller@ics.u-strasbg.fr> | 2008-06-11 22:03:49 +0000 |
commit | b80817856c4ba9ec9275cf2c9f43dd485cd0ac41 (patch) | |
tree | 86284274864ff0d669caaaba3e2e18e8c9597e52 /gdb/i386-tdep.c | |
parent | ac7ff656fe11088f6b6b743c80dd4420e3977fbd (diff) | |
download | gdb-b80817856c4ba9ec9275cf2c9f43dd485cd0ac41.tar.gz |
* gdbarch.sh (gdbarch_skip_main_prologue): New.
* gdbarch.h, gdbarch.c: Regenerate.
* i386-tdep.h (i386_skip_main_prologue): Declare.
* i386-tdep.c (i386_skip_main_prologue): New.
* i386-cygwin-tdep.c (i386_cygwin_init_abi): Register
i386_skip_main_prologue as gdbarch_skip_main_prologue gdbarch callback.
* symtab.c (find_function_start_sal): When pc points at the "main"
function, call gdbarch_skip_main_prologue.
Diffstat (limited to 'gdb/i386-tdep.c')
-rw-r--r-- | gdb/i386-tdep.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index be4f4f38dfe..91bd7d040b2 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1160,6 +1160,38 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) return pc; } +/* Check that the code pointed to by PC corresponds to a call to + __main, skip it if so. Return PC otherwise. */ + +CORE_ADDR +i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + 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) + { + /* Make sure address is computed correctly as a 32bit + integer even if CORE_ADDR is 64 bit wide. */ + struct minimal_symbol *s; + CORE_ADDR call_dest = pc + 5 + extract_signed_integer (buf, 4); + + call_dest = call_dest & 0xffffffffU; + 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; +} + /* This function is 64-bit safe. */ static CORE_ADDR |