struct field_of_this_result *);
static
-struct symbol *lookup_symbol_aux_local (const char *name,
- const struct block *block,
- const domain_enum domain,
- enum language language);
+struct symbol *lookup_local_symbol (const char *name,
+ const struct block *block,
+ const domain_enum domain,
+ enum language language);
static
-struct symbol *lookup_symbol_aux_symtabs (int block_index,
- const char *name,
- const domain_enum domain);
-
-static
-struct symbol *lookup_symbol_aux_quick (struct objfile *objfile,
- int block_index,
- const char *name,
- const domain_enum domain);
+struct symbol *lookup_symbol_via_quick_fns (struct objfile *objfile,
+ int block_index,
+ const char *name,
+ const domain_enum domain);
extern initialize_file_ftype _initialize_symtab;
return 0;
}
-struct symtab *
-find_pc_sect_symtab_via_partial (CORE_ADDR pc, struct obj_section *section)
+/* See symtab.h. */
+
+void
+expand_symtab_containing_pc (CORE_ADDR pc, struct obj_section *section)
{
struct objfile *objfile;
struct bound_minimal_symbol msymbol;
|| MSYMBOL_TYPE (msymbol.minsym) == mst_abs
|| MSYMBOL_TYPE (msymbol.minsym) == mst_file_data
|| MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss))
- return NULL;
+ return;
ALL_OBJFILES (objfile)
{
- struct symtab *result = NULL;
+ struct symtab *s = NULL;
if (objfile->sf)
- result = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol,
- pc, section, 0);
- if (result)
- return result;
+ s = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol,
+ pc, section, 0);
+ if (s != NULL)
+ return;
}
-
- return NULL;
}
\f
/* Debug symbols usually don't have section information. We need to dig that
gdb_assert (objfile || SYMBOL_SYMTAB (sym));
if (objfile == NULL)
- objfile = SYMBOL_SYMTAB (sym)->objfile;
+ objfile = SYMBOL_OBJFILE (sym);
if (SYMBOL_OBJ_SECTION (objfile, sym))
return sym;
/* Search specified block and its superiors. Don't search
STATIC_BLOCK or GLOBAL_BLOCK. */
- sym = lookup_symbol_aux_local (name, block, domain, language);
+ sym = lookup_local_symbol (name, block, domain, language);
if (sym != NULL)
return sym;
/* Now search all static file-level symbols. Not strictly correct,
but more useful than an error. */
- return lookup_static_symbol_aux (name, domain);
-}
-
-/* See symtab.h. */
-
-struct symbol *
-lookup_static_symbol_aux (const char *name, const domain_enum domain)
-{
- struct objfile *objfile;
- struct symbol *sym;
-
- sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain);
- if (sym != NULL)
- return sym;
-
- ALL_OBJFILES (objfile)
- {
- sym = lookup_symbol_aux_quick (objfile, STATIC_BLOCK, name, domain);
- if (sym != NULL)
- return sym;
- }
-
- return NULL;
+ return lookup_static_symbol (name, domain);
}
/* Check to see if the symbol is defined in BLOCK or its superiors.
Don't search STATIC_BLOCK or GLOBAL_BLOCK. */
static struct symbol *
-lookup_symbol_aux_local (const char *name, const struct block *block,
- const domain_enum domain,
- enum language language)
+lookup_local_symbol (const char *name, const struct block *block,
+ const domain_enum domain,
+ enum language language)
{
struct symbol *sym;
const struct block *static_block = block_static_block (block);
while (block != static_block)
{
- sym = lookup_symbol_aux_block (name, block, domain);
+ sym = lookup_symbol_in_block (name, block, domain);
if (sym != NULL)
return sym;
/* See symtab.h. */
struct symbol *
-lookup_symbol_aux_block (const char *name, const struct block *block,
- const domain_enum domain)
+lookup_symbol_in_block (const char *name, const struct block *block,
+ const domain_enum domain)
{
struct symbol *sym;
}
}
- sym = lookup_symbol_aux_quick ((struct objfile *) objfile, GLOBAL_BLOCK,
- name, domain);
+ sym = lookup_symbol_via_quick_fns ((struct objfile *) objfile,
+ GLOBAL_BLOCK, name, domain);
if (sym)
return sym;
}
static symbols. */
static struct symbol *
-lookup_symbol_aux_objfile (struct objfile *objfile, int block_index,
- const char *name, const domain_enum domain)
+lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
+ const char *name, const domain_enum domain)
{
struct symbol *sym = NULL;
const struct blockvector *bv;
return NULL;
}
-/* Same as lookup_symbol_aux_objfile, except that it searches all
- objfiles. Return the first match found. */
-
-static struct symbol *
-lookup_symbol_aux_symtabs (int block_index, const char *name,
- const domain_enum domain)
-{
- struct symbol *sym;
- struct objfile *objfile;
-
- ALL_OBJFILES (objfile)
- {
- sym = lookup_symbol_aux_objfile (objfile, block_index, name, domain);
- if (sym)
- return sym;
- }
-
- return NULL;
-}
-
-/* Wrapper around lookup_symbol_aux_objfile for search_symbols.
+/* Wrapper around lookup_symbol_in_objfile_symtabs for search_symbols.
Look up LINKAGE_NAME in DOMAIN in the global and static blocks of OBJFILE
and all related objfiles. */
{
struct symbol *sym;
- sym = lookup_symbol_aux_objfile (cur_objfile, GLOBAL_BLOCK,
- modified_name, domain);
+ sym = lookup_symbol_in_objfile_symtabs (cur_objfile, GLOBAL_BLOCK,
+ modified_name, domain);
if (sym == NULL)
- sym = lookup_symbol_aux_objfile (cur_objfile, STATIC_BLOCK,
- modified_name, domain);
+ sym = lookup_symbol_in_objfile_symtabs (cur_objfile, STATIC_BLOCK,
+ modified_name, domain);
if (sym != NULL)
{
do_cleanups (cleanup);
name, symtab_to_filename_for_display (symtab), name, name);
}
-/* A helper function for lookup_symbol_aux that interfaces with the
- "quick" symbol table functions. */
+/* A helper function for various lookup routines that interfaces with
+ the "quick" symbol table functions. */
static struct symbol *
-lookup_symbol_aux_quick (struct objfile *objfile, int block_index,
- const char *name, const domain_enum domain)
+lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
+ const char *name, const domain_enum domain)
{
struct symtab *symtab;
const struct blockvector *bv;
not it would be appropriate to search the current global block
here as well. (That's what this code used to do before the
is_a_field_of_this check was moved up.) On the one hand, it's
- redundant with the lookup_symbol_aux_symtabs search that happens
+ redundant with the lookup in all objfiles search that happens
next. On the other hand, if decode_line_1 is passed an argument
like filename:var, then the user presumably wants 'var' to be
searched for in filename. On the third hand, there shouldn't be
than that one, so I don't think we should worry about that for
now. */
- sym = lookup_symbol_static (name, block, domain);
+ /* NOTE: dje/2014-10-26: The lookup in all objfiles search could skip
+ the current objfile. Searching the current objfile first is useful
+ for both matching user expectations as well as performance. */
+
+ sym = lookup_symbol_in_static_block (name, block, domain);
if (sym != NULL)
return sym;
- return lookup_symbol_global (name, block, domain);
+ return lookup_global_symbol (name, block, domain);
}
/* See symtab.h. */
struct symbol *
-lookup_symbol_static (const char *name,
- const struct block *block,
- const domain_enum domain)
+lookup_symbol_in_static_block (const char *name,
+ const struct block *block,
+ const domain_enum domain)
{
const struct block *static_block = block_static_block (block);
if (static_block != NULL)
- return lookup_symbol_aux_block (name, static_block, domain);
+ return lookup_symbol_in_block (name, static_block, domain);
else
return NULL;
}
+/* Perform the standard symbol lookup of NAME in OBJFILE:
+ 1) First search expanded symtabs, and if not found
+ 2) Search the "quick" symtabs (partial or .gdb_index).
+ BLOCK_INDEX is one of GLOBAL_BLOCK or STATIC_BLOCK. */
+
+static struct symbol *
+lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
+ const char *name, const domain_enum domain)
+{
+ struct symbol *result;
+
+ result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
+ name, domain);
+ if (result == NULL)
+ {
+ result = lookup_symbol_via_quick_fns (objfile, block_index,
+ name, domain);
+ }
+
+ return result;
+}
+
+/* See symtab.h. */
+
+struct symbol *
+lookup_static_symbol (const char *name, const domain_enum domain)
+{
+ struct objfile *objfile;
+ struct symbol *result;
+
+ ALL_OBJFILES (objfile)
+ {
+ result = lookup_symbol_in_objfile (objfile, STATIC_BLOCK, name, domain);
+ if (result != NULL)
+ return result;
+ }
+
+ return NULL;
+}
+
/* Private data to be used with lookup_symbol_global_iterator_cb. */
struct global_sym_lookup_data
gdb_assert (data->result == NULL);
- data->result = lookup_symbol_aux_objfile (objfile, GLOBAL_BLOCK,
- data->name, data->domain);
- if (data->result == NULL)
- data->result = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK,
- data->name, data->domain);
+ data->result = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK,
+ data->name, data->domain);
/* If we found a match, tell the iterator to stop. Otherwise,
keep going. */
/* See symtab.h. */
struct symbol *
-lookup_symbol_global (const char *name,
+lookup_global_symbol (const char *name,
const struct block *block,
const domain_enum domain)
{
}
bv = BLOCKVECTOR (s);
- objfile = s->objfile;
+ objfile = SYMTAB_OBJFILE (s);
/* Look at all the symtabs that share this blockvector.
They all have the same apriori range, that we found was right;
continue;
/* Find the best line in this symtab. */
- l = LINETABLE (s);
+ l = SYMTAB_LINETABLE (s);
if (!l)
continue;
len = l->nitems;
pc = overlay_mapped_address (pc, section);
return find_pc_sect_line (pc, section, notcurrent);
}
+
+/* See symtab.h. */
+
+struct symtab *
+find_pc_line_symtab (CORE_ADDR pc)
+{
+ struct symtab_and_line sal;
+
+ /* This always passes zero for NOTCURRENT to find_pc_line.
+ There are currently no callers that ever pass non-zero. */
+ sal = find_pc_line (pc, 0);
+ return sal.symtab;
+}
\f
/* Find line number LINE in any symtab whose name is the same as
SYMTAB.
struct symtab *best_symtab;
/* First try looking it up in the given symtab. */
- best_linetable = LINETABLE (symtab);
+ best_linetable = SYMTAB_LINETABLE (symtab);
best_symtab = symtab;
best_index = find_line_common (best_linetable, line, &exact, 0);
if (best_index < 0 || !exact)
if (FILENAME_CMP (symtab_to_fullname (symtab),
symtab_to_fullname (s)) != 0)
continue;
- l = LINETABLE (s);
+ l = SYMTAB_LINETABLE (s);
ind = find_line_common (l, line, &exact, 0);
if (ind >= 0)
{
int was_exact;
int idx;
- idx = find_line_common (LINETABLE (symtab), line, &was_exact, start);
+ idx = find_line_common (SYMTAB_LINETABLE (symtab), line, &was_exact,
+ start);
if (idx < 0)
break;
if (!was_exact)
{
- struct linetable_entry *item = &LINETABLE (symtab)->item[idx];
+ struct linetable_entry *item = &SYMTAB_LINETABLE (symtab)->item[idx];
if (*best_item == NULL || item->line < (*best_item)->line)
*best_item = item;
break;
}
- VEC_safe_push (CORE_ADDR, result, LINETABLE (symtab)->item[idx].pc);
+ VEC_safe_push (CORE_ADDR, result,
+ SYMTAB_LINETABLE (symtab)->item[idx].pc);
start = idx + 1;
}
symtab = find_line_symtab (symtab, line, &ind, NULL);
if (symtab != NULL)
{
- l = LINETABLE (symtab);
+ l = SYMTAB_LINETABLE (symtab);
*pc = l->item[ind].pc;
return 1;
}
int i;
/* Give up if this symbol has no lineinfo table. */
- l = LINETABLE (symtab);
+ l = SYMTAB_LINETABLE (symtab);
if (l == NULL)
return func_addr;
pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym);
name = SYMBOL_LINKAGE_NAME (sym);
- objfile = SYMBOL_SYMTAB (sym)->objfile;
+ objfile = SYMBOL_OBJFILE (sym);
}
else
{
}
}
-/* Determine if PC is in the prologue of a function. The prologue is the area
- between the first instruction of a function, and the first executable line.
- Returns 1 if PC *might* be in prologue, 0 if definately *not* in prologue.
-
- If non-zero, func_start is where we think the prologue starts, possibly
- by previous examination of symbol table information. */
-
-int
-in_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR func_start)
-{
- struct symtab_and_line sal;
- CORE_ADDR func_addr, func_end;
-
- /* We have several sources of information we can consult to figure
- this out.
- - Compilers usually emit line number info that marks the prologue
- as its own "source line". So the ending address of that "line"
- is the end of the prologue. If available, this is the most
- reliable method.
- - The minimal symbols and partial symbols, which can usually tell
- us the starting and ending addresses of a function.
- - If we know the function's start address, we can call the
- architecture-defined gdbarch_skip_prologue function to analyze the
- instruction stream and guess where the prologue ends.
- - Our `func_start' argument; if non-zero, this is the caller's
- best guess as to the function's entry point. At the time of
- this writing, handle_inferior_event doesn't get this right, so
- it should be our last resort. */
-
- /* Consult the partial symbol table, to find which function
- the PC is in. */
- if (! find_pc_partial_function (pc, NULL, &func_addr, &func_end))
- {
- CORE_ADDR prologue_end;
-
- /* We don't even have minsym information, so fall back to using
- func_start, if given. */
- if (! func_start)
- return 1; /* We *might* be in a prologue. */
-
- prologue_end = gdbarch_skip_prologue (gdbarch, func_start);
-
- return func_start <= pc && pc < prologue_end;
- }
-
- /* If we have line number information for the function, that's
- usually pretty reliable. */
- sal = find_pc_line (func_addr, 0);
-
- /* Now sal describes the source line at the function's entry point,
- which (by convention) is the prologue. The end of that "line",
- sal.end, is the end of the prologue.
-
- Note that, for functions whose source code is all on a single
- line, the line number information doesn't always end up this way.
- So we must verify that our purported end-of-prologue address is
- *within* the function, not at its start or end. */
- if (sal.line == 0
- || sal.end <= func_addr
- || func_end <= sal.end)
- {
- /* We don't have any good line number info, so use the minsym
- information, together with the architecture-specific prologue
- scanning code. */
- CORE_ADDR prologue_end = gdbarch_skip_prologue (gdbarch, func_addr);
-
- return func_addr <= pc && pc < prologue_end;
- }
-
- /* We have line number info, and it looks good. */
- return func_addr <= pc && pc < sal.end;
-}
-
/* Given PC at the function's start address, attempt to find the
prologue end using SAL information. Return zero if the skip fails.
do this. */
if (prologue_sal.symtab->language != language_asm)
{
- struct linetable *linetable = LINETABLE (prologue_sal.symtab);
+ struct linetable *linetable = SYMTAB_LINETABLE (prologue_sal.symtab);
int idx = 0;
/* Skip any earlier lines, and any end-of-sequence marker