/* Symbol table lookup for the GNU debugger, GDB.
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GDB.
#include "observer.h"
#include "gdb_assert.h"
#include "solist.h"
+#include "macrotab.h"
+#include "macroscope.h"
/* Prototypes for local functions */
const struct block *block,
const domain_enum domain,
enum language language,
- int *is_a_field_of_this,
- struct symtab **symtab);
+ int *is_a_field_of_this);
static
struct symbol *lookup_symbol_aux_local (const char *name,
const char *linkage_name,
const struct block *block,
- const domain_enum domain,
- struct symtab **symtab);
+ const domain_enum domain);
static
struct symbol *lookup_symbol_aux_symtabs (int block_index,
const char *name,
const char *linkage_name,
- const domain_enum domain,
- struct symtab **symtab);
+ const domain_enum domain);
static
struct symbol *lookup_symbol_aux_psymtabs (int block_index,
const char *name,
const char *linkage_name,
- const domain_enum domain,
- struct symtab **symtab);
-
-static void fixup_section (struct general_symbol_info *, struct objfile *);
+ const domain_enum domain);
static int file_matches (char *, char **, int);
/* 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;
not include the data ranges. */
msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
if (msymbol
- && (msymbol->type == mst_data
- || msymbol->type == mst_bss
- || msymbol->type == mst_abs
- || msymbol->type == mst_file_data
- || msymbol->type == mst_file_bss))
+ && (MSYMBOL_TYPE (msymbol) == mst_data
+ || MSYMBOL_TYPE (msymbol) == mst_bss
+ || MSYMBOL_TYPE (msymbol) == mst_abs
+ || MSYMBOL_TYPE (msymbol) == mst_file_data
+ || MSYMBOL_TYPE (msymbol) == mst_file_bss))
return NULL;
/* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
pst = addrmap_find (objfile->psymtabs_addrmap, pc);
if (pst != NULL)
{
+ /* FIXME: addrmaps currently do not handle overlayed sections,
+ so fall back to the non-addrmap case if we're debugging
+ overlays and the addrmap returned the wrong section. */
+ if (overlay_debugging && msymbol && section)
+ {
+ struct partial_symbol *p;
+ /* NOTE: This assumes that every psymbol has a
+ corresponding msymbol, which is not necessarily
+ true; the debug info might be much richer than the
+ object's symbol table. */
+ p = find_pc_sect_psymbol (pst, pc, section);
+ if (!p
+ || SYMBOL_VALUE_ADDRESS (p)
+ != SYMBOL_VALUE_ADDRESS (msymbol))
+ continue;
+ }
+
/* We do not try to call FIND_PC_SECT_PSYMTAB_CLOSER as
PSYMTABS_ADDRMAP we used has already the best 1-byte
granularity and FIND_PC_SECT_PSYMTAB_CLOSER may mislead us into
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);
out of the minimal symbols and stash that in the debug symbol. */
static void
-fixup_section (struct general_symbol_info *ginfo, struct objfile *objfile)
+fixup_section (struct general_symbol_info *ginfo,
+ CORE_ADDR addr, struct objfile *objfile)
{
struct minimal_symbol *msym;
- msym = lookup_minimal_symbol (ginfo->name, NULL, objfile);
/* First, check whether a minimal symbol with the same name exists
and points to the same address. The address check is required
e.g. on PowerPC64, where the minimal symbol for a function will
point to the function descriptor, while the debug symbol will
point to the actual function code. */
- if (msym
- && SYMBOL_VALUE_ADDRESS (msym) == ginfo->value.address)
+ 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 if (objfile)
+ else
{
/* Static, function-local variables do appear in the linker
(minimal) symbols, but are frequently given names that won't
this reason, we still attempt a lookup by name prior to doing
a search of the section table. */
- CORE_ADDR addr;
struct obj_section *s;
-
- addr = ginfo->value.address;
-
ALL_OBJFILE_OSECTIONS (objfile, s)
{
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;
}
struct symbol *
fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
{
+ CORE_ADDR addr;
+
if (!sym)
return NULL;
- if (SYMBOL_BFD_SECTION (sym))
+ if (SYMBOL_OBJ_SECTION (sym))
return sym;
- fixup_section (&sym->ginfo, objfile);
+ /* We either have an OBJFILE, or we can get at it from the sym's
+ symtab. Anything else is a bug. */
+ gdb_assert (objfile || SYMBOL_SYMTAB (sym));
+
+ if (objfile == NULL)
+ objfile = SYMBOL_SYMTAB (sym)->objfile;
+
+ /* We should have an objfile by now. */
+ gdb_assert (objfile);
+
+ switch (SYMBOL_CLASS (sym))
+ {
+ case LOC_STATIC:
+ case LOC_LABEL:
+ addr = SYMBOL_VALUE_ADDRESS (sym);
+ break;
+ case LOC_BLOCK:
+ addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ break;
+
+ default:
+ /* Nothing else will be listed in the minsyms -- no use looking
+ it up. */
+ return sym;
+ }
+
+ fixup_section (&sym->ginfo, addr, objfile);
return sym;
}
struct partial_symbol *
fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
{
+ CORE_ADDR addr;
+
if (!psym)
return NULL;
- if (SYMBOL_BFD_SECTION (psym))
+ if (SYMBOL_OBJ_SECTION (psym))
return psym;
- fixup_section (&psym->ginfo, objfile);
+ gdb_assert (objfile);
+
+ switch (SYMBOL_CLASS (psym))
+ {
+ case LOC_STATIC:
+ case LOC_LABEL:
+ case LOC_BLOCK:
+ addr = SYMBOL_VALUE_ADDRESS (psym);
+ break;
+ default:
+ /* Nothing else will be listed in the minsyms -- no use looking
+ it up. */
+ return psym;
+ }
+
+ fixup_section (&psym->ginfo, addr, objfile);
return psym;
}
/* Find the definition for a specified symbol name NAME
in domain DOMAIN, visible from lexical block BLOCK.
Returns the struct symbol pointer, or zero if no symbol is found.
- If SYMTAB is non-NULL, store the symbol table in which the
- symbol was found there, or NULL if not found.
C++: if IS_A_FIELD_OF_THIS is nonzero on entry, check to see if
NAME is a field of the current implied argument `this'. If so set
*IS_A_FIELD_OF_THIS to 1, otherwise set it to zero.
struct symbol *
lookup_symbol_in_language (const char *name, const struct block *block,
const domain_enum domain, enum language lang,
- int *is_a_field_of_this,
- struct symtab **symtab)
+ int *is_a_field_of_this)
{
char *demangled_name = NULL;
const char *modified_name = NULL;
}
returnval = lookup_symbol_aux (modified_name, mangled_name, block,
- domain, lang,
- is_a_field_of_this, symtab);
+ domain, lang, is_a_field_of_this);
if (needtofreename)
xfree (demangled_name);
- /* Override the returned symtab with the symbol's specific one. */
- if (returnval != NULL && symtab != NULL)
- *symtab = SYMBOL_SYMTAB (returnval);
-
return returnval;
}
struct symbol *
lookup_symbol (const char *name, const struct block *block,
- domain_enum domain, int *is_a_field_of_this,
- struct symtab **symtab)
+ domain_enum domain, int *is_a_field_of_this)
{
return lookup_symbol_in_language (name, block, domain,
current_language->la_language,
- is_a_field_of_this, symtab);
+ is_a_field_of_this);
}
/* Behave like lookup_symbol except that NAME is the natural name
static struct symbol *
lookup_symbol_aux (const char *name, const char *linkage_name,
const struct block *block, const domain_enum domain,
- enum language language,
- int *is_a_field_of_this, struct symtab **symtab)
+ enum language language, int *is_a_field_of_this)
{
struct symbol *sym;
const struct language_defn *langdef;
/* Search specified block and its superiors. Don't search
STATIC_BLOCK or GLOBAL_BLOCK. */
- sym = lookup_symbol_aux_local (name, linkage_name, block, domain,
- symtab);
+ sym = lookup_symbol_aux_local (name, linkage_name, block, domain);
if (sym != NULL)
return sym;
if (check_field (t, name))
{
*is_a_field_of_this = 1;
- if (symtab != NULL)
- *symtab = NULL;
return NULL;
}
}
/* Now do whatever is appropriate for LANGUAGE to look
up static and global variables. */
- sym = langdef->la_lookup_symbol_nonlocal (name, linkage_name,
- block, domain, symtab);
+ sym = langdef->la_lookup_symbol_nonlocal (name, linkage_name, block, domain);
if (sym != NULL)
return sym;
desired name as a file-level static, then do psymtab-to-symtab
conversion on the fly and return the found symbol. */
- sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, linkage_name,
- domain, symtab);
+ sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, linkage_name, domain);
if (sym != NULL)
return sym;
- sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, linkage_name,
- domain, symtab);
+ sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, linkage_name, domain);
if (sym != NULL)
return sym;
- if (symtab != NULL)
- *symtab = NULL;
return NULL;
}
static struct symbol *
lookup_symbol_aux_local (const char *name, const char *linkage_name,
const struct block *block,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
struct symbol *sym;
const struct block *static_block = block_static_block (block);
while (block != static_block)
{
- sym = lookup_symbol_aux_block (name, linkage_name, block, domain,
- symtab);
+ sym = lookup_symbol_aux_block (name, linkage_name, block, domain);
if (sym != NULL)
return sym;
block = BLOCK_SUPERBLOCK (block);
return NULL;
}
-/* Look up a symbol in a block; if found, locate its symtab, fixup the
- symbol, and set block_found appropriately. */
+/* Look up a symbol in a block; if found, fixup the symbol, and set
+ block_found appropriately. */
struct symbol *
lookup_symbol_aux_block (const char *name, const char *linkage_name,
const struct block *block,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
struct symbol *sym;
- struct objfile *objfile = NULL;
- struct blockvector *bv;
- struct block *b;
- struct symtab *s = NULL;
sym = lookup_block_symbol (block, name, linkage_name, domain);
if (sym)
{
block_found = block;
- if (symtab != NULL)
- {
- /* Search the list of symtabs for one which contains the
- address of the start of this block. */
- ALL_PRIMARY_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- if (BLOCK_START (b) <= BLOCK_START (block)
- && BLOCK_END (b) > BLOCK_START (block))
- goto found;
- }
- found:
- *symtab = s;
- }
-
- return fixup_symbol_section (sym, objfile);
+ return fixup_symbol_section (sym, NULL);
}
return NULL;
lookup_global_symbol_from_objfile (const struct objfile *objfile,
const char *name,
const char *linkage_name,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
struct symbol *sym;
struct blockvector *bv;
if (sym)
{
block_found = block;
- if (symtab != NULL)
- *symtab = s;
return fixup_symbol_section (sym, (struct objfile *)objfile);
}
}
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
sym = lookup_block_symbol (block, name, linkage_name, domain);
- if (symtab != NULL)
- *symtab = s;
return fixup_symbol_section (sym, (struct objfile *)objfile);
}
}
if (objfile->separate_debug_objfile)
return lookup_global_symbol_from_objfile (objfile->separate_debug_objfile,
- name, linkage_name, domain,
- symtab);
+ name, linkage_name, domain);
return NULL;
}
static struct symbol *
lookup_symbol_aux_symtabs (int block_index,
const char *name, const char *linkage_name,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
struct symbol *sym;
struct objfile *objfile;
if (sym)
{
block_found = block;
- if (symtab != NULL)
- *symtab = s;
return fixup_symbol_section (sym, objfile);
}
}
static struct symbol *
lookup_symbol_aux_psymtabs (int block_index, const char *name,
const char *linkage_name,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
struct symbol *sym;
struct objfile *objfile;
block_index == GLOBAL_BLOCK ? "global" : "static",
name, ps->filename, name, name);
}
- if (symtab != NULL)
- *symtab = s;
return fixup_symbol_section (sym, objfile);
}
}
basic_lookup_symbol_nonlocal (const char *name,
const char *linkage_name,
const struct block *block,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
struct symbol *sym;
than that one, so I don't think we should worry about that for
now. */
- sym = lookup_symbol_static (name, linkage_name, block, domain, symtab);
+ sym = lookup_symbol_static (name, linkage_name, block, domain);
if (sym != NULL)
return sym;
- return lookup_symbol_global (name, linkage_name, block, domain, symtab);
+ return lookup_symbol_global (name, linkage_name, block, domain);
}
/* Lookup a symbol in the static block associated to BLOCK, if there
lookup_symbol_static (const char *name,
const char *linkage_name,
const struct block *block,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
const struct block *static_block = block_static_block (block);
if (static_block != NULL)
- return lookup_symbol_aux_block (name, linkage_name, static_block,
- domain, symtab);
+ return lookup_symbol_aux_block (name, linkage_name, static_block, domain);
else
return NULL;
}
lookup_symbol_global (const char *name,
const char *linkage_name,
const struct block *block,
- const domain_enum domain,
- struct symtab **symtab)
+ const domain_enum domain)
{
struct symbol *sym = NULL;
struct objfile *objfile = NULL;
/* Call library-specific lookup procedure. */
objfile = lookup_objfile_from_block (block);
if (objfile != NULL)
- sym = solib_global_lookup (objfile, name, linkage_name, domain, symtab);
+ sym = solib_global_lookup (objfile, name, linkage_name, domain);
if (sym != NULL)
return sym;
- sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, linkage_name,
- domain, symtab);
+ sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, linkage_name, domain);
if (sym != NULL)
return sym;
- return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, linkage_name,
- domain, symtab);
+ return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, linkage_name, domain);
}
int
? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
{
sym_found = sym;
- if (SYMBOL_CLASS (sym) != LOC_ARG &&
- SYMBOL_CLASS (sym) != LOC_LOCAL_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;
on the partial_symtab's texthigh and textlow. */
msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
if (msymbol
- && (msymbol->type == mst_data
- || msymbol->type == mst_bss
- || msymbol->type == mst_abs
- || msymbol->type == mst_file_data
- || msymbol->type == mst_file_bss))
+ && (MSYMBOL_TYPE (msymbol) == mst_data
+ || MSYMBOL_TYPE (msymbol) == mst_bss
+ || MSYMBOL_TYPE (msymbol) == mst_abs
+ || MSYMBOL_TYPE (msymbol) == mst_file_data
+ || MSYMBOL_TYPE (msymbol) == mst_file_bss))
return NULL;
/* Search all symtabs for the one whose file contains our address, and which
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;
Only symbols of KIND are searched:
FUNCTIONS_DOMAIN - search all functions
TYPES_DOMAIN - search all type names
- METHODS_DOMAIN - search all methods NOT IMPLEMENTED
VARIABLES_DOMAIN - search all symbols, excluding functions, type names,
and constants (enums)
&& ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
&& SYMBOL_CLASS (*psym) != LOC_BLOCK)
|| (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (*psym) == LOC_BLOCK)
- || (kind == TYPES_DOMAIN && SYMBOL_CLASS (*psym) == LOC_TYPEDEF)
- || (kind == METHODS_DOMAIN && SYMBOL_CLASS (*psym) == LOC_BLOCK))))
+ || (kind == TYPES_DOMAIN && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))))
{
PSYMTAB_TO_SYMTAB (ps);
keep_going = 0;
if (kind == FUNCTIONS_DOMAIN
|| lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol),
(struct block *) NULL,
- VAR_DOMAIN,
- 0, (struct symtab **) NULL)
+ VAR_DOMAIN, 0)
== NULL)
found_misc = 1;
}
&& SYMBOL_CLASS (sym) != LOC_BLOCK
&& SYMBOL_CLASS (sym) != LOC_CONST)
|| (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (sym) == LOC_BLOCK)
- || (kind == TYPES_DOMAIN && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- || (kind == METHODS_DOMAIN && SYMBOL_CLASS (sym) == LOC_BLOCK))))
+ || (kind == TYPES_DOMAIN && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
{
/* match */
psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
{
/* Variables/Absolutes: Look up by name */
if (lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol),
- (struct block *) NULL, VAR_DOMAIN,
- 0, (struct symtab **) NULL) == NULL)
+ (struct block *) NULL, VAR_DOMAIN, 0)
+ == NULL)
{
/* match */
psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
return p;
}
+/* Type of the user_data argument passed to add_macro_name. The
+ contents are simply whatever is needed by
+ completion_list_add_name. */
+struct add_macro_name_data
+{
+ char *sym_text;
+ int sym_text_len;
+ char *text;
+ char *word;
+};
+
+/* A callback used with macro_for_each and macro_for_each_in_scope.
+ This adds a macro's name to the current completion list. */
+static void
+add_macro_name (const char *name, const struct macro_definition *ignore,
+ void *user_data)
+{
+ struct add_macro_name_data *datum = (struct add_macro_name_data *) user_data;
+ completion_list_add_name ((char *) name,
+ datum->sym_text, datum->sym_text_len,
+ datum->text, datum->word);
+}
+
char **
default_make_symbol_completion_list (char *text, char *word)
{
}
}
+ if (current_language->la_macro_expansion == macro_expansion_c)
+ {
+ struct macro_scope *scope;
+ struct add_macro_name_data datum;
+
+ datum.sym_text = sym_text;
+ datum.sym_text_len = sym_text_len;
+ datum.text = text;
+ datum.word = word;
+
+ /* Add any macros visible in the default scope. Note that this
+ may yield the occasional wrong result, because an expression
+ might be evaluated in a scope other than the default. For
+ example, if the user types "break file:line if <TAB>", the
+ resulting expression will be evaluated at "file:line" -- but
+ at there does not seem to be a way to detect this at
+ completion time. */
+ scope = default_macro_scope ();
+ if (scope)
+ {
+ macro_for_each_in_scope (scope->file, scope->line,
+ add_macro_name, &datum);
+ xfree (scope);
+ }
+
+ /* User-defined macros are always visible. */
+ macro_for_each (macro_user_macros, add_macro_name, &datum);
+ }
+
return (return_val);
}
struct symtab_and_line prologue_sal;
CORE_ADDR start_pc;
CORE_ADDR end_pc;
+ struct block *bl;
/* Get an initial range for the function. */
find_pc_partial_function (func_addr, NULL, &start_pc, &end_pc);
prologue_sal = find_pc_line (start_pc, 0);
if (prologue_sal.line != 0)
{
+ /* For langauges other than assembly, treat two consecutive line
+ entries at the same address as a zero-instruction prologue.
+ The GNU assembler emits separate line notes for each instruction
+ in a multi-instruction macro, but compilers generally will not
+ do this. */
+ if (prologue_sal.symtab->language != language_asm)
+ {
+ struct linetable *linetable = LINETABLE (prologue_sal.symtab);
+ int exact;
+ int idx = 0;
+
+ /* Skip any earlier lines, and any end-of-sequence marker
+ from a previous function. */
+ while (linetable->item[idx].pc != prologue_sal.pc
+ || linetable->item[idx].line == 0)
+ idx++;
+
+ if (idx+1 < linetable->nitems
+ && linetable->item[idx+1].line != 0
+ && linetable->item[idx+1].pc == start_pc)
+ return start_pc;
+ }
+
/* If there is only one sal that covers the entire function,
then it is probably a single line function, like
"foo(){}". */
if (prologue_sal.end >= end_pc)
return 0;
+
while (prologue_sal.end < end_pc)
{
struct symtab_and_line sal;
prologue_sal = sal;
}
}
- return prologue_sal.end;
+
+ if (prologue_sal.end < end_pc)
+ /* Return the end of this line, or zero if we could not find a
+ line. */
+ return prologue_sal.end;
+ else
+ /* Don't return END_PC, which is past the end of the function. */
+ return prologue_sal.pc;
}
\f
struct symtabs_and_lines
/* 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;