* 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.
This commit is contained in:
parent
a4e2ee12f0
commit
4309257cda
8 changed files with 102 additions and 0 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2008-06-12 Pedro Alves <pedro_alves@portugalmail.pt>
|
||||||
|
Pierre Muller <muller@ics.u-strasbg.fr>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2008-06-11 Daniel Jacobowitz <dan@codesourcery.com>
|
2008-06-11 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
* value.c (value_primitive_field): Fetch lazy register values.
|
* value.c (value_primitive_field): Fetch lazy register values.
|
||||||
|
|
|
@ -183,6 +183,7 @@ struct gdbarch
|
||||||
gdbarch_integer_to_address_ftype *integer_to_address;
|
gdbarch_integer_to_address_ftype *integer_to_address;
|
||||||
gdbarch_return_value_ftype *return_value;
|
gdbarch_return_value_ftype *return_value;
|
||||||
gdbarch_skip_prologue_ftype *skip_prologue;
|
gdbarch_skip_prologue_ftype *skip_prologue;
|
||||||
|
gdbarch_skip_main_prologue_ftype *skip_main_prologue;
|
||||||
gdbarch_inner_than_ftype *inner_than;
|
gdbarch_inner_than_ftype *inner_than;
|
||||||
gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc;
|
gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc;
|
||||||
gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address;
|
gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address;
|
||||||
|
@ -313,6 +314,7 @@ struct gdbarch startup_gdbarch =
|
||||||
0, /* integer_to_address */
|
0, /* integer_to_address */
|
||||||
0, /* return_value */
|
0, /* return_value */
|
||||||
0, /* skip_prologue */
|
0, /* skip_prologue */
|
||||||
|
0, /* skip_main_prologue */
|
||||||
0, /* inner_than */
|
0, /* inner_than */
|
||||||
0, /* breakpoint_from_pc */
|
0, /* breakpoint_from_pc */
|
||||||
0, /* adjust_breakpoint_address */
|
0, /* adjust_breakpoint_address */
|
||||||
|
@ -561,6 +563,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
|
||||||
/* Skip verify of return_value, has predicate */
|
/* Skip verify of return_value, has predicate */
|
||||||
if (gdbarch->skip_prologue == 0)
|
if (gdbarch->skip_prologue == 0)
|
||||||
fprintf_unfiltered (log, "\n\tskip_prologue");
|
fprintf_unfiltered (log, "\n\tskip_prologue");
|
||||||
|
/* Skip verify of skip_main_prologue, has predicate */
|
||||||
if (gdbarch->inner_than == 0)
|
if (gdbarch->inner_than == 0)
|
||||||
fprintf_unfiltered (log, "\n\tinner_than");
|
fprintf_unfiltered (log, "\n\tinner_than");
|
||||||
if (gdbarch->breakpoint_from_pc == 0)
|
if (gdbarch->breakpoint_from_pc == 0)
|
||||||
|
@ -998,6 +1001,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
|
||||||
fprintf_unfiltered (file,
|
fprintf_unfiltered (file,
|
||||||
"gdbarch_dump: single_step_through_delay = <0x%lx>\n",
|
"gdbarch_dump: single_step_through_delay = <0x%lx>\n",
|
||||||
(long) gdbarch->single_step_through_delay);
|
(long) gdbarch->single_step_through_delay);
|
||||||
|
fprintf_unfiltered (file,
|
||||||
|
"gdbarch_dump: gdbarch_skip_main_prologue_p() = %d\n",
|
||||||
|
gdbarch_skip_main_prologue_p (gdbarch));
|
||||||
|
fprintf_unfiltered (file,
|
||||||
|
"gdbarch_dump: skip_main_prologue = <0x%lx>\n",
|
||||||
|
(long) gdbarch->skip_main_prologue);
|
||||||
fprintf_unfiltered (file,
|
fprintf_unfiltered (file,
|
||||||
"gdbarch_dump: gdbarch_skip_permanent_breakpoint_p() = %d\n",
|
"gdbarch_dump: gdbarch_skip_permanent_breakpoint_p() = %d\n",
|
||||||
gdbarch_skip_permanent_breakpoint_p (gdbarch));
|
gdbarch_skip_permanent_breakpoint_p (gdbarch));
|
||||||
|
@ -2122,6 +2131,30 @@ set_gdbarch_skip_prologue (struct gdbarch *gdbarch,
|
||||||
gdbarch->skip_prologue = skip_prologue;
|
gdbarch->skip_prologue = skip_prologue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
gdbarch_skip_main_prologue_p (struct gdbarch *gdbarch)
|
||||||
|
{
|
||||||
|
gdb_assert (gdbarch != NULL);
|
||||||
|
return gdbarch->skip_main_prologue != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CORE_ADDR
|
||||||
|
gdbarch_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR ip)
|
||||||
|
{
|
||||||
|
gdb_assert (gdbarch != NULL);
|
||||||
|
gdb_assert (gdbarch->skip_main_prologue != NULL);
|
||||||
|
if (gdbarch_debug >= 2)
|
||||||
|
fprintf_unfiltered (gdb_stdlog, "gdbarch_skip_main_prologue called\n");
|
||||||
|
return gdbarch->skip_main_prologue (gdbarch, ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_gdbarch_skip_main_prologue (struct gdbarch *gdbarch,
|
||||||
|
gdbarch_skip_main_prologue_ftype skip_main_prologue)
|
||||||
|
{
|
||||||
|
gdbarch->skip_main_prologue = skip_main_prologue;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs)
|
gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -379,6 +379,12 @@ typedef CORE_ADDR (gdbarch_skip_prologue_ftype) (struct gdbarch *gdbarch, CORE_A
|
||||||
extern CORE_ADDR gdbarch_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip);
|
extern CORE_ADDR gdbarch_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip);
|
||||||
extern void set_gdbarch_skip_prologue (struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue);
|
extern void set_gdbarch_skip_prologue (struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue);
|
||||||
|
|
||||||
|
extern int gdbarch_skip_main_prologue_p (struct gdbarch *gdbarch);
|
||||||
|
|
||||||
|
typedef CORE_ADDR (gdbarch_skip_main_prologue_ftype) (struct gdbarch *gdbarch, CORE_ADDR ip);
|
||||||
|
extern CORE_ADDR gdbarch_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR ip);
|
||||||
|
extern void set_gdbarch_skip_main_prologue (struct gdbarch *gdbarch, gdbarch_skip_main_prologue_ftype *skip_main_prologue);
|
||||||
|
|
||||||
typedef int (gdbarch_inner_than_ftype) (CORE_ADDR lhs, CORE_ADDR rhs);
|
typedef int (gdbarch_inner_than_ftype) (CORE_ADDR lhs, CORE_ADDR rhs);
|
||||||
extern int gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs);
|
extern int gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs);
|
||||||
extern void set_gdbarch_inner_than (struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than);
|
extern void set_gdbarch_inner_than (struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than);
|
||||||
|
|
|
@ -482,6 +482,7 @@ M:CORE_ADDR:integer_to_address:struct type *type, const gdb_byte *buf:type, buf
|
||||||
M:enum return_value_convention:return_value:struct type *functype, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf:functype, valtype, regcache, readbuf, writebuf
|
M:enum return_value_convention:return_value:struct type *functype, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf:functype, valtype, regcache, readbuf, writebuf
|
||||||
|
|
||||||
m:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip:0:0
|
m:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip:0:0
|
||||||
|
M:CORE_ADDR:skip_main_prologue:CORE_ADDR ip:ip
|
||||||
f:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0
|
f:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0
|
||||||
m:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:
|
m:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:
|
||||||
M:CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr
|
M:CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr
|
||||||
|
|
|
@ -227,6 +227,8 @@ i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
||||||
|
|
||||||
set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code);
|
set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code);
|
||||||
|
|
||||||
|
set_gdbarch_skip_main_prologue (gdbarch, i386_skip_main_prologue);
|
||||||
|
|
||||||
tdep->struct_return = reg_struct_return;
|
tdep->struct_return = reg_struct_return;
|
||||||
|
|
||||||
tdep->gregset_reg_offset = i386_win32_gregset_reg_offset;
|
tdep->gregset_reg_offset = i386_win32_gregset_reg_offset;
|
||||||
|
|
|
@ -1160,6 +1160,38 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
|
||||||
return 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. */
|
/* This function is 64-bit safe. */
|
||||||
|
|
||||||
static CORE_ADDR
|
static CORE_ADDR
|
||||||
|
|
|
@ -170,6 +170,7 @@ extern struct type *i386_sse_type (struct gdbarch *gdbarch);
|
||||||
|
|
||||||
/* Functions exported from i386-tdep.c. */
|
/* Functions exported from i386-tdep.c. */
|
||||||
extern CORE_ADDR i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name);
|
extern CORE_ADDR i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name);
|
||||||
|
extern CORE_ADDR i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc);
|
||||||
|
|
||||||
/* Return the name of register REGNUM. */
|
/* Return the name of register REGNUM. */
|
||||||
extern char const *i386_register_name (struct gdbarch * gdbarch, int regnum);
|
extern char const *i386_register_name (struct gdbarch * gdbarch, int regnum);
|
||||||
|
|
15
gdb/symtab.c
15
gdb/symtab.c
|
@ -2617,6 +2617,21 @@ find_function_start_sal (struct symbol *sym, int funfirstline)
|
||||||
/* Recalculate the line number (might not be N+1). */
|
/* Recalculate the line number (might not be N+1). */
|
||||||
sal = find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0);
|
sal = find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* On targets with executable formats that don't have a concept of
|
||||||
|
constructors (ELF with .init has, PE doesn't), gcc emits a call
|
||||||
|
to `__main' in `main' between the prologue and before user
|
||||||
|
code. */
|
||||||
|
if (funfirstline
|
||||||
|
&& gdbarch_skip_main_prologue_p (current_gdbarch)
|
||||||
|
&& SYMBOL_LINKAGE_NAME (sym)
|
||||||
|
&& strcmp (SYMBOL_LINKAGE_NAME (sym), "main") == 0)
|
||||||
|
{
|
||||||
|
pc = gdbarch_skip_main_prologue (current_gdbarch, pc);
|
||||||
|
/* Recalculate the line number (might not be N+1). */
|
||||||
|
sal = find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0);
|
||||||
|
}
|
||||||
|
|
||||||
sal.pc = pc;
|
sal.pc = pc;
|
||||||
|
|
||||||
return sal;
|
return sal;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue