/* Return the demangled name for a symbol based on the language for
that symbol. If no demangled name exists, return NULL. */
char *
-symbol_demangled_name (struct general_symbol_info *gsymbol)
+symbol_demangled_name (const struct general_symbol_info *gsymbol)
{
switch (gsymbol->language)
{
file and another in a separated debug file. */
int
-matching_bfd_sections (asection *first, asection *second)
+matching_obj_sections (struct obj_section *obj_first,
+ struct obj_section *obj_second)
{
+ asection *first = obj_first? obj_first->the_bfd_section : NULL;
+ asection *second = obj_second? obj_second->the_bfd_section : NULL;
struct objfile *obj;
/* If they're the same section, then they match. */
We may find a different psymtab than PST. See FIND_PC_SECT_PSYMTAB. */
struct partial_symtab *
-find_pc_sect_psymtab_closer (CORE_ADDR pc, asection *section,
+find_pc_sect_psymtab_closer (CORE_ADDR pc, struct obj_section *section,
struct partial_symtab *pst,
struct minimal_symbol *msymbol)
{
exactly matches PC, or, if we cannot find an exact match, the
psymtab that contains a symbol whose address is closest to PC. */
struct partial_symtab *
-find_pc_sect_psymtab (CORE_ADDR pc, asection *section)
+find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section)
{
struct objfile *objfile;
struct minimal_symbol *msymbol;
struct partial_symbol *
find_pc_sect_psymbol (struct partial_symtab *psymtab, CORE_ADDR pc,
- asection *section)
+ struct obj_section *section)
{
struct partial_symbol *best = NULL, *p, **pp;
CORE_ADDR best_pc;
if (section) /* match on a specific section */
{
fixup_psymbol_section (p, psymtab->objfile);
- if (!matching_bfd_sections (SYMBOL_BFD_SECTION (p), section))
+ if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section))
continue;
}
best_pc = SYMBOL_VALUE_ADDRESS (p);
if (section) /* match on a specific section */
{
fixup_psymbol_section (p, psymtab->objfile);
- if (!matching_bfd_sections (SYMBOL_BFD_SECTION (p), section))
+ if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section))
continue;
}
best_pc = SYMBOL_VALUE_ADDRESS (p);
msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->name, objfile);
if (msym)
{
- ginfo->bfd_section = SYMBOL_BFD_SECTION (msym);
+ ginfo->obj_section = SYMBOL_OBJ_SECTION (msym);
ginfo->section = SYMBOL_SECTION (msym);
}
else
int idx = s->the_bfd_section->index;
CORE_ADDR offset = ANOFFSET (objfile->section_offsets, idx);
- if (s->addr - offset <= addr && addr < s->endaddr - offset)
+ if (obj_section_addr (s) - offset <= addr
+ && addr < obj_section_endaddr (s) - offset)
{
- ginfo->bfd_section = s->the_bfd_section;
+ ginfo->obj_section = s;
ginfo->section = idx;
return;
}
if (!sym)
return NULL;
- if (SYMBOL_BFD_SECTION (sym))
+ if (SYMBOL_OBJ_SECTION (sym))
return sym;
/* We either have an OBJFILE, or we can get at it from the sym's
if (!psym)
return NULL;
- if (SYMBOL_BFD_SECTION (psym))
+ if (SYMBOL_OBJ_SECTION (psym))
return psym;
gdb_assert (objfile);
? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
{
sym_found = sym;
- if (SYMBOL_CLASS (sym) != LOC_ARG &&
- SYMBOL_CLASS (sym) != LOC_REF_ARG &&
- SYMBOL_CLASS (sym) != LOC_REGPARM &&
- SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR &&
- SYMBOL_CLASS (sym) != LOC_BASEREG_ARG &&
- SYMBOL_CLASS (sym) != LOC_COMPUTED_ARG)
+ if (!SYMBOL_IS_ARGUMENT (sym))
{
break;
}
psymtabs and read in another symtab if necessary. */
struct symtab *
-find_pc_sect_symtab (CORE_ADDR pc, asection *section)
+find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
{
struct block *b;
struct blockvector *bv;
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
fixup_symbol_section (sym, objfile);
- if (matching_bfd_sections (SYMBOL_BFD_SECTION (sym), section))
+ if (matching_obj_sections (SYMBOL_OBJ_SECTION (sym), section))
break;
}
if (sym == NULL)
/* If it's worth the effort, we could be using a binary search. */
struct symtab_and_line
-find_pc_sect_line (CORE_ADDR pc, struct bfd_section *section, int notcurrent)
+find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
{
struct symtab *s;
struct linetable *l;
struct symtab_and_line
find_pc_line (CORE_ADDR pc, int notcurrent)
{
- asection *section;
+ struct obj_section *section;
section = find_pc_overlay (pc);
if (pc_in_unmapped_range (pc, section))
address after the function prologue. */
CORE_ADDR
find_function_start_pc (struct gdbarch *gdbarch,
- CORE_ADDR pc, asection *section)
+ CORE_ADDR pc, struct obj_section *section)
{
/* If the function is in an unmapped overlay, use its unmapped LMA address,
so that gdbarch_skip_prologue has something unique to work on. */
if (funfirstline)
{
/* Skip "first line" of function (which is actually its prologue). */
- pc = find_function_start_pc (gdbarch, pc, SYMBOL_BFD_SECTION (sym));
+ pc = find_function_start_pc (gdbarch, pc, SYMBOL_OBJ_SECTION (sym));
}
- sal = find_pc_sect_line (pc, SYMBOL_BFD_SECTION (sym), 0);
+ sal = find_pc_sect_line (pc, SYMBOL_OBJ_SECTION (sym), 0);
/* Check if gdbarch_skip_prologue left us in mid-line, and the next
line is still part of the same function. */
/* First pc of next line */
pc = sal.end;
/* 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_OBJ_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_OBJ_SECTION (sym), 0);
+ }
+
sal.pc = pc;
return sal;
/* Handle ``executable_changed'' events for the symtab module. */
static void
-symtab_observer_executable_changed (void *unused)
+symtab_observer_executable_changed (void)
{
/* NAME_OF_MAIN may no longer be the same, so reset it for now. */
set_main_name (NULL);
blocks -- for each PC found above we see if there are other PCs
that are in the same block. If yes, the other PCs are filtered out. */
- filter = xmalloc (ret.nelts * sizeof (int));
- blocks = xmalloc (ret.nelts * sizeof (struct block *));
+ filter = alloca (ret.nelts * sizeof (int));
+ blocks = alloca (ret.nelts * sizeof (struct block *));
for (i = 0; i < ret.nelts; ++i)
{
filter[i] = 1;