int *is_a_field_of_this,
struct symtab **symtab);
+static struct symbol *lookup_symbol_aux_local (const char *name,
+ const char *mangled_name,
+ const struct block *block,
+ const namespace_enum namespace,
+ struct symtab **symtab);
+
+static
+struct symbol *lookup_symbol_aux_symtabs (int block_index,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace,
+ struct symtab **symtab);
+
+static
+struct symbol *lookup_symbol_aux_minsyms (const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace,
+ int *is_a_field_of_this,
+ struct symtab **symtab);
+
+static
+struct symbol *lookup_symbol_aux_psymtabs (int block_index,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace,
+ struct symtab **symtab);
static struct symbol *find_active_alias (struct symbol *sym, CORE_ADDR addr);
{
return s;
}
-
+
/* If the user gave us an absolute path, try to find the file in
this symtab and use its absolute path. */
-
+
if (full_path != NULL)
{
const char *fp = symtab_to_filename (s);
if (real_path != NULL)
{
char *rp = gdb_realpath (symtab_to_filename (s));
- make_cleanup (xfree, rp);
+ make_cleanup (xfree, rp);
if (FILENAME_CMP (real_path, rp) == 0)
{
return s;
if (real_path != NULL)
{
- char *rp = NULL;
+ char *rp = NULL;
if (pst->fullname == NULL)
source_full_path_of (pst->filename, &pst->fullname);
- if (pst->fullname != NULL)
- {
- rp = gdb_realpath (pst->fullname);
- make_cleanup (xfree, rp);
- }
+ if (pst->fullname != NULL)
+ {
+ rp = gdb_realpath (pst->fullname);
+ make_cleanup (xfree, rp);
+ }
if (rp != NULL && FILENAME_CMP (real_path, rp) == 0)
{
return pst;
mangled_name_len = ((is_constructor ? 0 : strlen (field_name))
+ strlen (buf) + len + strlen (physname) + 1);
- {
- mangled_name = (char *) xmalloc (mangled_name_len);
- if (is_constructor)
- mangled_name[0] = '\0';
- else
- strcpy (mangled_name, field_name);
- }
+ {
+ mangled_name = (char *) xmalloc (mangled_name_len);
+ if (is_constructor)
+ mangled_name[0] = '\0';
+ else
+ strcpy (mangled_name, field_name);
+ }
strcat (mangled_name, buf);
/* If the class doesn't have a name, i.e. newname NULL, then we just
mangle it using 0 for the length of the class. Thus it gets mangled
strcat (mangled_name, physname);
return (mangled_name);
}
-
\f
+
/* Initialize a symbol's mangled name. */
/* Try to initialize the demangled name for a symbol, based on the
void
symbol_init_demangled_name (struct general_symbol_info *gsymbol,
- struct obstack *obstack)
+ struct obstack *obstack)
{
char *mangled = gsymbol->name;
char *demangled = NULL;
if (gsymbol->language == language_cplus
|| gsymbol->language == language_auto)
{
- demangled =
- cplus_demangle (gsymbol->name, DMGL_PARAMS | DMGL_ANSI);
+ demangled = cplus_demangle (gsymbol->name, DMGL_PARAMS | DMGL_ANSI);
if (demangled != NULL)
- {
- gsymbol->language = language_cplus;
- gsymbol->language_specific.cplus_specific.demangled_name =
- obsavestring (demangled, strlen (demangled), obstack);
- xfree (demangled);
- }
+ {
+ gsymbol->language = language_cplus;
+ gsymbol->language_specific.cplus_specific.demangled_name =
+ obsavestring (demangled, strlen (demangled), obstack);
+ xfree (demangled);
+ }
else
- {
- gsymbol->language_specific.cplus_specific.demangled_name = NULL;
- }
+ {
+ gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+ }
}
if (gsymbol->language == language_java)
{
demangled =
- cplus_demangle (gsymbol->name,
- DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
+ cplus_demangle (gsymbol->name, DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
if (demangled != NULL)
- {
- gsymbol->language = language_java;
- gsymbol->language_specific.cplus_specific.demangled_name =
- obsavestring (demangled, strlen (demangled), obstack);
- xfree (demangled);
- }
+ {
+ gsymbol->language = language_java;
+ gsymbol->language_specific.cplus_specific.demangled_name =
+ obsavestring (demangled, strlen (demangled), obstack);
+ xfree (demangled);
+ }
else
- {
- gsymbol->language_specific.cplus_specific.demangled_name = NULL;
- }
+ {
+ gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+ }
}
#if 0
/* OBSOLETE if (demangled == NULL */
/* OBSOLETE } */
#endif
}
+\f
-\f
/* Find which partial symtab on contains PC and SECTION. Return 0 if none. */
struct partial_symtab *
-find_pc_sect_psymtab (CORE_ADDR pc, asection *section)
+find_pc_sect_psymtab (CORE_ADDR pc, asection * section)
{
register struct partial_symtab *pst;
register struct objfile *objfile;
&& (msymbol->type == mst_data
|| msymbol->type == mst_bss
|| msymbol->type == mst_abs
- || msymbol->type == mst_file_data
- || msymbol->type == mst_file_bss))
+ || msymbol->type == mst_file_data || msymbol->type == mst_file_bss))
return NULL;
ALL_PSYMTABS (objfile, pst)
many partial symbol tables containing the PC, but
we want the partial symbol table that contains the
function containing the PC. */
- if (!(objfile->flags & OBJF_REORDERED) &&
- section == 0) /* can't validate section this way */
+ if (!(objfile->flags & OBJF_REORDERED) && section == 0) /* can't validate section this way */
return (pst);
if (msymbol == NULL)
struct partial_symbol *
find_pc_sect_psymbol (struct partial_symtab *psymtab, CORE_ADDR pc,
- asection *section)
+ asection * section)
{
struct partial_symbol *best = NULL, *p, **pp;
CORE_ADDR best_pc;
find_pc_partial_function doesn't use a minimal symbol and thus
cache a bad endaddr. */
for (pp = psymtab->objfile->global_psymbols.list + psymtab->globals_offset;
- (pp - (psymtab->objfile->global_psymbols.list + psymtab->globals_offset)
- < psymtab->n_global_syms);
- pp++)
+ (pp -
+ (psymtab->objfile->global_psymbols.list + psymtab->globals_offset) <
+ psymtab->n_global_syms); pp++)
{
p = *pp;
if (SYMBOL_NAMESPACE (p) == VAR_NAMESPACE
}
for (pp = psymtab->objfile->static_psymbols.list + psymtab->statics_offset;
- (pp - (psymtab->objfile->static_psymbols.list + psymtab->statics_offset)
- < psymtab->n_static_syms);
- pp++)
+ (pp -
+ (psymtab->objfile->static_psymbols.list + psymtab->statics_offset) <
+ psymtab->n_static_syms); pp++)
{
p = *pp;
if (SYMBOL_NAMESPACE (p) == VAR_NAMESPACE
len = strlen (name);
copy = (char *) alloca (len + 1);
- for (i= 0; i < len; i++)
- copy[i] = tolower (name[i]);
+ for (i = 0; i < len; i++)
+ copy[i] = tolower (name[i]);
copy[len] = 0;
modified_name = copy;
}
if (needtofreename)
xfree (demangled_name);
- return returnval;
+ return returnval;
}
static struct symbol *
const struct block *block, const namespace_enum namespace,
int *is_a_field_of_this, struct symtab **symtab)
{
- register struct symbol *sym;
- register struct symtab *s = NULL;
- register struct partial_symtab *ps;
- register struct blockvector *bv;
- register struct objfile *objfile = NULL;
- register struct block *b;
- register struct minimal_symbol *msymbol;
-
+ struct symbol *sym;
/* Search specified block and its superiors. */
- while (block != 0)
- {
- sym = lookup_block_symbol (block, name, mangled_name, namespace);
- 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_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);
- }
- block = BLOCK_SUPERBLOCK (block);
- }
-
- /* FIXME: this code is never executed--block is always NULL at this
- point. What is it trying to do, anyway? We already should have
- checked the STATIC_BLOCK above (it is the superblock of top-level
- blocks). Why is VAR_NAMESPACE special-cased? */
- /* Don't need to mess with the psymtabs; if we have a block,
- that file is read in. If we don't, then we deal later with
- all the psymtab stuff that needs checking. */
- /* Note (RT): The following never-executed code looks unnecessary to me also.
- * If we change the code to use the original (passed-in)
- * value of 'block', we could cause it to execute, but then what
- * would it do? The STATIC_BLOCK of the symtab containing the passed-in
- * 'block' was already searched by the above code. And the STATIC_BLOCK's
- * of *other* symtabs (those files not containing 'block' lexically)
- * should not contain 'block' address-wise. So we wouldn't expect this
- * code to find any 'sym''s that were not found above. I vote for
- * deleting the following paragraph of code.
- */
- if (namespace == VAR_NAMESPACE && block != NULL)
- {
- struct block *b;
- /* Find the right symtab. */
- ALL_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- if (BLOCK_START (b) <= BLOCK_START (block)
- && BLOCK_END (b) > BLOCK_START (block))
- {
- sym = lookup_block_symbol (b, name, mangled_name, VAR_NAMESPACE);
- if (sym)
- {
- block_found = b;
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
- }
- }
- }
- }
-
+ sym = lookup_symbol_aux_local (name, mangled_name, block, namespace,
+ symtab);
+ if (sym != NULL)
+ return sym;
/* C++: If requested to do so by the caller,
check to see if NAME is a field of `this'. */
of the desired name as a global, then do psymtab-to-symtab
conversion on the fly and return the found symbol. */
- ALL_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, mangled_name, namespace);
- if (sym)
- {
- block_found = block;
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
- }
- }
+ sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, mangled_name,
+ namespace, symtab);
+ if (sym != NULL)
+ return sym;
+
+ sym = lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, mangled_name,
+ namespace, symtab);
+ if (sym != NULL)
+ return sym;
#ifndef HPUXHPPA
- /* Check for the possibility of the symbol being a function or
- a mangled variable that is stored in one of the minimal symbol tables.
- Eventually, all global symbols might be resolved in this way. */
+ /* Check for the possibility of the symbol being a function or a
+ mangled variable that is stored in one of the minimal symbol
+ tables. Eventually, all global symbols might be resolved in this
+ way. */
- if (namespace == VAR_NAMESPACE)
- {
- msymbol = lookup_minimal_symbol (name, NULL, NULL);
- if (msymbol != NULL)
- {
- s = find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol),
- SYMBOL_BFD_SECTION (msymbol));
- if (s != NULL)
- {
- /* This is a function which has a symtab for its address. */
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_symbol_aux_minsyms (name, mangled_name,
+ namespace, is_a_field_of_this,
+ symtab);
+ if (sym != NULL)
+ return sym;
- /* This call used to pass `SYMBOL_NAME (msymbol)' as the
- `name' argument to lookup_block_symbol. But the name
- of a minimal symbol is always mangled, so that seems
- to be clearly the wrong thing to pass as the
- unmangled name. */
- sym = lookup_block_symbol (block, name, mangled_name, namespace);
- /* We kept static functions in minimal symbol table as well as
- in static scope. We want to find them in the symbol table. */
- if (!sym)
- {
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name,
- mangled_name, namespace);
- }
+#endif
- /* sym == 0 if symbol was found in the minimal symbol table
- but not in the symtab.
- Return 0 to use the msymbol definition of "foo_".
+ /* Now search all static file-level symbols. Not strictly correct,
+ but more useful than an error. Do the symtabs first, then check
+ the psymtabs. If a psymtab indicates the existence of the
+ desired name as a file-level static, then do psymtab-to-symtab
+ conversion on the fly and return the found symbol. */
- This happens for Fortran "foo_" symbols,
- which are "foo" in the symtab.
+ sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, mangled_name,
+ namespace, symtab);
+ if (sym != NULL)
+ return sym;
+
+ sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, mangled_name,
+ namespace, symtab);
+ if (sym != NULL)
+ return sym;
- This can also happen if "asm" is used to make a
- regular symbol but not a debugging symbol, e.g.
- asm(".globl _main");
- asm("_main:");
- */
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
- }
- else if (MSYMBOL_TYPE (msymbol) != mst_text
- && MSYMBOL_TYPE (msymbol) != mst_file_text
- && !STREQ (name, SYMBOL_NAME (msymbol)))
+#ifdef HPUXHPPA
+
+ /* Check for the possibility of the symbol being a function or a
+ global variable that is stored in one of the minimal symbol
+ tables. The "minimal symbol table" is built from linker-supplied
+ info.
+
+ RT: I moved this check to last, after the complete search of the
+ global (p)symtab's and static (p)symtab's. For HP-generated
+ symbol tables, this check was causing a premature exit from
+ lookup_symbol with NULL return, and thus messing up symbol
+ lookups of things like "c::f". It seems to me a check of the
+ minimal symbol table ought to be a last resort in any case. I'm
+ vaguely worried about the comment within
+ lookup_symbol_aux_minsyms which talks about FORTRAN routines
+ "foo_" though... is it saying we need to do the "minsym" check
+ before the static check in this case? */
+
+ sym = lookup_symbol_aux_minsyms (name, mangled_name,
+ namespace, is_a_field_of_this,
+ symtab);
+ if (sym != NULL)
+ return sym;
+
+#endif
+
+ if (symtab != NULL)
+ *symtab = NULL;
+ return NULL;
+}
+
+/* Check to see if the symbol is defined in BLOCK or its
+ superiors. */
+
+static struct symbol *
+lookup_symbol_aux_local (const char *name, const char *mangled_name,
+ const struct block *block,
+ const namespace_enum namespace,
+ struct symtab **symtab)
+{
+ struct symbol *sym;
+ struct objfile *objfile = NULL;
+ struct blockvector *bv;
+ struct block *b;
+ struct symtab *s = NULL;
+
+ while (block != 0)
+ {
+ sym = lookup_block_symbol (block, name, mangled_name, namespace);
+ if (sym)
+ {
+ block_found = block;
+ if (symtab != NULL)
{
- /* This is a mangled variable, look it up by its
- mangled name. */
- return lookup_symbol_aux (SYMBOL_NAME (msymbol), mangled_name, block,
- namespace, is_a_field_of_this, symtab);
+ /* Search the list of symtabs for one which contains the
+ address of the start of this block. */
+ ALL_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;
}
- /* There are no debug symbols for this file, or we are looking
- for an unmangled variable.
- Try to find a matching static symbol below. */
+
+ return fixup_symbol_section (sym, objfile);
}
+ block = BLOCK_SUPERBLOCK (block);
}
-#endif
+ return NULL;
+}
- ALL_PSYMTABS (objfile, ps)
- {
- if (!ps->readin && lookup_partial_symbol (ps, name, 1, namespace))
- {
- s = PSYMTAB_TO_SYMTAB (ps);
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, mangled_name, namespace);
- if (!sym)
- {
- /* This shouldn't be necessary, but as a last resort
- * try looking in the statics even though the psymtab
- * claimed the symbol was global. It's possible that
- * the psymtab gets it wrong in some cases.
- */
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, mangled_name, namespace);
- if (!sym)
- error ("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
-%s may be an inlined function, or may be a template function\n\
-(if a template, try specifying an instantiation: %s<type>).",
- name, ps->filename, name, name);
- }
- if (symtab != NULL)
- *symtab = s;
- return fixup_symbol_section (sym, objfile);
- }
- }
+/* Check to see if the symbol is defined in one of the symtabs.
+ BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK,
+ depending on whether or not we want to search global symbols or
+ local symbols. */
- /* Now search all static file-level symbols.
- Not strictly correct, but more useful than an error.
- Do the symtabs first, then check the psymtabs.
- If a psymtab indicates the existence
- of the desired name as a file-level static, then do psymtab-to-symtab
- conversion on the fly and return the found symbol. */
+static struct symbol *
+lookup_symbol_aux_symtabs (int block_index,
+ const char *name, const char *mangled_name,
+ const namespace_enum namespace,
+ struct symtab **symtab)
+{
+ struct symbol *sym;
+ struct objfile *objfile;
+ struct blockvector *bv;
+ const struct block *block;
+ struct symtab *s;
ALL_SYMTABS (objfile, s)
{
bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = lookup_block_symbol (block, name, mangled_name, namespace);
if (sym)
{
}
}
+ return NULL;
+}
+
+/* Check to see if the symbol is defined in one of the partial
+ symtabs. BLOCK_INDEX should be either GLOBAL_BLOCK or
+ STATIC_BLOCK, depending on whether or not we want to search global
+ symbols or local symbols. */
+
+static struct symbol *
+lookup_symbol_aux_psymtabs (int block_index, const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace,
+ struct symtab **symtab)
+{
+ struct symbol *sym;
+ struct objfile *objfile;
+ struct blockvector *bv;
+ const struct block *block;
+ struct partial_symtab *ps;
+ struct symtab *s;
+ const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
+
ALL_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace))
+ if (!ps->readin
+ && lookup_partial_symbol (ps, name, psymtab_index, namespace))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = lookup_block_symbol (block, name, mangled_name, namespace);
if (!sym)
{
- /* This shouldn't be necessary, but as a last resort
- * try looking in the globals even though the psymtab
- * claimed the symbol was static. It's possible that
- * the psymtab gets it wrong in some cases.
- */
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ /* This shouldn't be necessary, but as a last resort try
+ looking in the statics even though the psymtab claimed
+ the symbol was global, or vice-versa. It's possible
+ that the psymtab gets it wrong in some cases. */
+
+ /* FIXME: carlton/2002-09-30: Should we really do that?
+ If that happens, isn't it likely to be a GDB error, in
+ which case we should fix the GDB error rather than
+ silently dealing with it here. So I'd vote for
+ removing the check for the symbol in the other
+ block. */
+ block = BLOCKVECTOR_BLOCK (bv,
+ block_index == GLOBAL_BLOCK ?
+ STATIC_BLOCK : GLOBAL_BLOCK);
sym = lookup_block_symbol (block, name, mangled_name, namespace);
if (!sym)
- error ("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
-%s may be an inlined function, or may be a template function\n\
-(if a template, try specifying an instantiation: %s<type>).",
+ error ("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>).",
+ block_index == GLOBAL_BLOCK ? "global" : "static",
name, ps->filename, name, name);
}
if (symtab != NULL)
}
}
-#ifdef HPUXHPPA
+ return NULL;
+}
- /* Check for the possibility of the symbol being a function or
- a global variable that is stored in one of the minimal symbol tables.
- The "minimal symbol table" is built from linker-supplied info.
+/* Check for the possibility of the symbol being a function or a
+ mangled variable that is stored in one of the minimal symbol
+ tables. Eventually, all global symbols might be resolved in this
+ way. */
- RT: I moved this check to last, after the complete search of
- the global (p)symtab's and static (p)symtab's. For HP-generated
- symbol tables, this check was causing a premature exit from
- lookup_symbol with NULL return, and thus messing up symbol lookups
- of things like "c::f". It seems to me a check of the minimal
- symbol table ought to be a last resort in any case. I'm vaguely
- worried about the comment below which talks about FORTRAN routines "foo_"
- though... is it saying we need to do the "minsym" check before
- the static check in this case?
- */
+static struct symbol *
+lookup_symbol_aux_minsyms (const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace,
+ int *is_a_field_of_this,
+ struct symtab **symtab)
+{
+ struct symbol *sym;
+ struct blockvector *bv;
+ const struct block *block;
+ struct minimal_symbol *msymbol;
+ struct symtab *s;
if (namespace == VAR_NAMESPACE)
{
msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
{
- /* OK, we found a minimal symbol in spite of not
- * finding any symbol. There are various possible
- * explanations for this. One possibility is the symbol
- * exists in code not compiled -g. Another possibility
- * is that the 'psymtab' isn't doing its job.
- * A third possibility, related to #2, is that we were confused
- * by name-mangling. For instance, maybe the psymtab isn't
- * doing its job because it only know about demangled
- * names, but we were given a mangled name...
- */
-
- /* We first use the address in the msymbol to try to
- * locate the appropriate symtab. Note that find_pc_symtab()
- * has a side-effect of doing psymtab-to-symtab expansion,
- * for the found symtab.
- */
- s = find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol));
+ /* OK, we found a minimal symbol in spite of not finding any
+ symbol. There are various possible explanations for
+ this. One possibility is the symbol exists in code not
+ compiled -g. Another possibility is that the 'psymtab'
+ isn't doing its job. A third possibility, related to #2,
+ is that we were confused by name-mangling. For instance,
+ maybe the psymtab isn't doing its job because it only
+ know about demangled names, but we were given a mangled
+ name... */
+
+ /* We first use the address in the msymbol to try to locate
+ the appropriate symtab. Note that find_pc_sect_symtab()
+ has a side-effect of doing psymtab-to-symtab expansion,
+ for the found symtab. */
+ s = find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol),
+ SYMBOL_BFD_SECTION (msymbol));
if (s != NULL)
{
+ /* This is a function which has a symtab for its address. */
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- /* This call used to pass `SYMBOL_NAME (msymbol)' as the
- `name' argument to lookup_block_symbol. But the name
- of a minimal symbol is always mangled, so that seems
- to be clearly the wrong thing to pass as the
- unmangled name. */
- sym = lookup_block_symbol (block, name, mangled_name, namespace);
+
+ /* This call used to pass `SYMBOL_NAME (msymbol)' as the
+ `name' argument to lookup_block_symbol. But the name
+ of a minimal symbol is always mangled, so that seems
+ to be clearly the wrong thing to pass as the
+ unmangled name. */
+ sym =
+ lookup_block_symbol (block, name, mangled_name, namespace);
/* We kept static functions in minimal symbol table as well as
in static scope. We want to find them in the symbol table. */
if (!sym)
{
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
sym = lookup_block_symbol (block, name,
- mangled_name, namespace);
- }
- /* If we found one, return it */
- if (sym)
- {
- if (symtab != NULL)
- *symtab = s;
- return sym;
+ mangled_name, namespace);
}
- /* If we get here with sym == 0, the symbol was
- found in the minimal symbol table
+ /* sym == 0 if symbol was found in the minimal symbol table
but not in the symtab.
- Fall through and return 0 to use the msymbol
- definition of "foo_".
- (Note that outer code generally follows up a call
- to this routine with a call to lookup_minimal_symbol(),
- so a 0 return means we'll just flow into that other routine).
+ Return 0 to use the msymbol definition of "foo_".
This happens for Fortran "foo_" symbols,
which are "foo" in the symtab.
asm(".globl _main");
asm("_main:");
*/
- }
- /* If the lookup-by-address fails, try repeating the
- * entire lookup process with the symbol name from
- * the msymbol (if different from the original symbol name).
- */
+ if (symtab != NULL)
+ *symtab = s;
+ return fixup_symbol_section (sym, s->objfile);
+ }
else if (MSYMBOL_TYPE (msymbol) != mst_text
&& MSYMBOL_TYPE (msymbol) != mst_file_text
&& !STREQ (name, SYMBOL_NAME (msymbol)))
{
+ /* This is a mangled variable, look it up by its
+ mangled name. */
return lookup_symbol_aux (SYMBOL_NAME (msymbol), mangled_name,
- block, namespace, is_a_field_of_this,
+ NULL, namespace, is_a_field_of_this,
symtab);
}
}
}
-#endif
-
- if (symtab != NULL)
- *symtab = NULL;
- return 0;
+ return NULL;
}
-
+
/* Look, in partial_symtab PST, for symbol NAME. Check the global
symbols if GLOBAL, the static symbols if not */
static struct partial_symbol *
-lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
- namespace_enum namespace)
+lookup_partial_symbol (struct partial_symtab *pst, const char *name,
+ int global, namespace_enum namespace)
{
struct partial_symbol *temp;
struct partial_symbol **start, **psym;
struct partial_symbol **top, **bottom, **center;
int length = (global ? pst->n_global_syms : pst->n_static_syms);
int do_linear_search = 1;
-
+
if (length == 0)
{
return (NULL);
start = (global ?
pst->objfile->global_psymbols.list + pst->globals_offset :
pst->objfile->static_psymbols.list + pst->statics_offset);
-
+
if (global) /* This means we can use a binary search. */
{
do_linear_search = 0;
{
center = bottom + (top - bottom) / 2;
if (!(center < top))
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
+ internal_error (__FILE__, __LINE__,
+ "failed internal consistency check");
if (!do_linear_search
&& (SYMBOL_LANGUAGE (*center) == language_java))
{
}
}
if (!(top == bottom))
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
+ internal_error (__FILE__, __LINE__,
+ "failed internal consistency check");
/* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
- we don't have to force a linear search on C++. Probably holds true
- for JAVA as well, no way to check.*/
- while (SYMBOL_MATCHES_NAME (*top,name))
+ we don't have to force a linear search on C++. Probably holds true
+ for JAVA as well, no way to check. */
+ while (SYMBOL_MATCHES_NAME (*top, name))
{
if (SYMBOL_NAMESPACE (*top) == namespace)
{
- return (*top);
+ return (*top);
}
top++;
}
we should also do a linear search. */
if (do_linear_search)
- {
+ {
for (psym = start; psym < start + length; psym++)
{
if (namespace == SYMBOL_NAMESPACE (*psym))
struct symbol *
lookup_block_symbol (register const struct block *block, const char *name,
- const char *mangled_name,
- const namespace_enum namespace)
+ const char *mangled_name, const namespace_enum namespace)
{
struct dict_iterator iter;
struct symbol *sym;
if (!BLOCK_FUNCTION (block))
{
for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
- sym;
- sym = dict_iter_name_next (name, &iter))
+ sym; sym = dict_iter_name_next (name, &iter))
{
- if (SYMBOL_NAMESPACE (sym) == namespace
+ if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
- ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
- : 1))
+ ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0 : 1))
return sym;
}
return NULL;
else
{
/* Note that parameter symbols do not always show up last in the
- list. This loop makes sure to take anything else other than
- parameter symbols first; it only uses parameter symbols as a
- last resort. Note that this only takes up extra computation
- time on a match. */
-
+ list. This loop makes sure to take anything else other than
+ parameter symbols first; it only uses parameter symbols as a
+ last resort. Note that this only takes up extra computation
+ time on a match. */
+
struct symbol *sym_found = NULL;
for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
- sym;
- sym = dict_iter_name_next (name, &iter))
+ sym; sym = dict_iter_name_next (name, &iter))
{
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
- ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
- : 1))
+ ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0 : 1))
{
/* If SYM has aliases, then use any alias that is active
at the current PC. If no alias is active at the current
?!? Is checking the current pc correct? Is this routine
ever called to look up a symbol from another context?
- FIXME: No, it's not correct. If someone sets a
- conditional breakpoint at an address, then the
- breakpoint's `struct expression' should refer to the
- `struct symbol' appropriate for the breakpoint's
- address, which may not be the PC.
+ FIXME: No, it's not correct. If someone sets a
+ conditional breakpoint at an address, then the
+ breakpoint's `struct expression' should refer to the
+ `struct symbol' appropriate for the breakpoint's
+ address, which may not be the PC.
- Even if it were never called from another context,
- it's totally bizarre for lookup_symbol's behavior to
- depend on the value of the inferior's current PC. We
- should pass in the appropriate PC as well as the
- block. The interface to lookup_symbol should change
- to require the caller to provide a PC. */
+ Even if it were never called from another context,
+ it's totally bizarre for lookup_symbol's behavior to
+ depend on the value of the inferior's current PC. We
+ should pass in the appropriate PC as well as the
+ block. The interface to lookup_symbol should change
+ to require the caller to provide a PC. */
if (SYMBOL_ALIASES (sym))
sym = find_active_alias (sym, read_pc ());
}
}
}
- return (sym_found); /* Will be NULL if not found. */
+ return (sym_found); /* Will be NULL if not found. */
}
}
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, asection * section)
{
register struct block *b;
struct blockvector *bv;
&& (msymbol->type == mst_data
|| msymbol->type == mst_bss
|| msymbol->type == mst_abs
- || msymbol->type == mst_file_data
- || msymbol->type == mst_file_bss))
+ || msymbol->type == mst_file_data || msymbol->type == mst_file_bss))
return NULL;
/* Search all symtabs for the one whose file contains our address, and which
if (BLOCK_START (b) <= pc
&& BLOCK_END (b) > pc
- && (distance == 0
- || BLOCK_END (b) - BLOCK_START (b) < distance))
+ && (distance == 0 || BLOCK_END (b) - BLOCK_START (b) < distance))
{
/* For an objfile that has its functions reordered,
find_pc_psymtab will find the proper partial symbol table
struct symbol *sym = NULL;
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- fixup_symbol_section (sym, objfile);
- if (section == SYMBOL_BFD_SECTION (sym))
- break;
- }
+ {
+ fixup_symbol_section (sym, objfile);
+ if (section == SYMBOL_BFD_SECTION (sym))
+ break;
+ }
if ((sym == NULL))
continue; /* no symbol in this symtab matches section */
}
will cause a core dump), but maybe we can successfully
continue, so let's not. */
warning ("\
-(Internal error: pc 0x%s in read in psymtab, but not in symtab.)\n",
- paddr_nz (pc));
+(Internal error: pc 0x%s in read in psymtab, but not in symtab.)\n", paddr_nz (pc));
s = PSYMTAB_TO_SYMTAB (ps);
}
return (s);
line *0x2345" cause psymtabs to be converted to symtabs). */
struct symbol *
-find_addr_symbol (CORE_ADDR addr, struct symtab **symtabp, CORE_ADDR *symaddrp)
+find_addr_symbol (CORE_ADDR addr, struct symtab **symtabp,
+ CORE_ADDR *symaddrp)
{
struct symtab *symtab, *best_symtab;
struct objfile *objfile;
QUIT;
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), blocknum);
ALL_BLOCK_SYMBOLS (block, iter, sym)
- {
- switch (SYMBOL_CLASS (sym))
- {
- case LOC_STATIC:
- case LOC_LABEL:
- sym_addr = SYMBOL_VALUE_ADDRESS (sym);
- break;
+ {
+ switch (SYMBOL_CLASS (sym))
+ {
+ case LOC_STATIC:
+ case LOC_LABEL:
+ sym_addr = SYMBOL_VALUE_ADDRESS (sym);
+ break;
- case LOC_INDIRECT:
- sym_addr = SYMBOL_VALUE_ADDRESS (sym);
- /* An indirect symbol really lives at *sym_addr,
- * so an indirection needs to be done.
- * However, I am leaving this commented out because it's
- * expensive, and it's possible that symbolization
- * could be done without an active process (in
- * case this read_memory will fail). RT
- sym_addr = read_memory_unsigned_integer
- (sym_addr, TARGET_PTR_BIT / TARGET_CHAR_BIT);
- */
- break;
+ case LOC_INDIRECT:
+ sym_addr = SYMBOL_VALUE_ADDRESS (sym);
+ /* An indirect symbol really lives at *sym_addr,
+ * so an indirection needs to be done.
+ * However, I am leaving this commented out because it's
+ * expensive, and it's possible that symbolization
+ * could be done without an active process (in
+ * case this read_memory will fail). RT
+ sym_addr = read_memory_unsigned_integer
+ (sym_addr, TARGET_PTR_BIT / TARGET_CHAR_BIT);
+ */
+ break;
- case LOC_BLOCK:
- sym_addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
- break;
+ case LOC_BLOCK:
+ sym_addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ break;
- default:
- continue;
- }
+ default:
+ continue;
+ }
- if (sym_addr <= addr)
- if (sym_addr > best_sym_addr)
- {
- /* Quit if we found an exact match. */
- best_sym = sym;
- best_sym_addr = sym_addr;
- best_symtab = symtab;
- if (sym_addr == addr)
- goto done;
- }
- }
+ if (sym_addr <= addr)
+ if (sym_addr > best_sym_addr)
+ {
+ /* Quit if we found an exact match. */
+ best_sym = sym;
+ best_sym_addr = sym_addr;
+ best_symtab = symtab;
+ if (sym_addr == addr)
+ goto done;
+ }
+ }
}
}
if (msymbol != NULL)
if (MSYMBOL_TYPE (msymbol) == mst_solib_trampoline)
{
- mfunsym = lookup_minimal_symbol_text (SYMBOL_NAME (msymbol), NULL, NULL);
+ mfunsym =
+ lookup_minimal_symbol_text (SYMBOL_NAME (msymbol), NULL, NULL);
if (mfunsym == NULL)
/* I eliminated this warning since it is coming out
* in the following situation:
* so of course we can't find the real func/line info,
* but the "break" still works, and the warning is annoying.
* So I commented out the warning. RT */
- /* warning ("In stub for %s; unable to find real function/line info", SYMBOL_NAME(msymbol)) */ ;
+ /* warning ("In stub for %s; unable to find real function/line info", SYMBOL_NAME(msymbol)) */
+ ;
/* fall through */
else if (SYMBOL_VALUE (mfunsym) == SYMBOL_VALUE (msymbol))
/* Avoid infinite recursion */
/* See above comment about why warning is commented out */
- /* warning ("In stub for %s; unable to find real function/line info", SYMBOL_NAME(msymbol)) */ ;
+ /* warning ("In stub for %s; unable to find real function/line info", SYMBOL_NAME(msymbol)) */
+ ;
/* fall through */
else
return find_pc_line (SYMBOL_VALUE (mfunsym), 0);
/* If another line (denoted by ITEM) is in the linetable and its
PC is after BEST's PC, but before the current BEST_END, then
- use ITEM's PC as the new best_end. */
+ use ITEM's PC as the new best_end. */
if (best && i < len && item->pc > best->pc
- && (best_end == 0 || best_end > item->pc))
+ && (best_end == 0 || best_end > item->pc))
best_end = item->pc;
}
else if (best->line == 0)
{
/* If our best fit is in a range of PC's for which no line
- number info is available (line number is zero) then we didn't
- find any valid line information. */
+ number info is available (line number is zero) then we didn't
+ find any valid line information. */
val.pc = pc;
}
else
If not found, return NULL. */
struct symtab *
-find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match)
+find_line_symtab (struct symtab *symtab, int line, int *index,
+ int *exact_match)
{
int exact;
asection *section = SYMBOL_BFD_SECTION (sym);
/* If function is in an unmapped overlay, use its unmapped LMA
address, so that SKIP_PROLOGUE has something unique to work on */
- if (section_is_overlay (section) &&
- !section_is_mapped (section))
+ if (section_is_overlay (section) && !section_is_mapped (section))
pc = overlay_unmapped_address (pc, section);
pc += FUNCTION_START_OFFSET;
while (*p)
switch (*p)
{
- case '\\': /* regexp quoting */
+ case '\\': /* regexp quoting */
if (p[1] == '*')
{
if (p[2] == '=') /* 'operator\*=' */
*end = p + 3;
- else /* 'operator\*' */
+ else /* 'operator\*' */
*end = p + 2;
return p;
}
else
error ("nothing is allowed between '[' and ']'");
}
- else
+ else
{
/* Gratuitous qoute: skip it and move on. */
p++;
return p;
case '(':
if (p[1] != ')')
- error ("`operator ()' must be specified without whitespace in `()'");
+ error
+ ("`operator ()' must be specified without whitespace in `()'");
*end = p + 2;
return p;
case '?':
if (p[1] != ':')
- error ("`operator ?:' must be specified without whitespace in `?:'");
+ error
+ ("`operator ?:' must be specified without whitespace in `?:'");
*end = p + 2;
return p;
case '[':
if (p[1] != ']')
- error ("`operator []' must be specified without whitespace in `[]'");
+ error
+ ("`operator []' must be specified without whitespace in `[]'");
*end = p + 2;
return p;
default:
}
printf_filtered ("\n\n");
- printf_filtered ("Source files for which symbols will be read in on demand:\n\n");
+ printf_filtered
+ ("Source files for which symbols will be read in on demand:\n\n");
first = 1;
ALL_PSYMTABS (objfile, ps)
struct minimal_symbol *msymbol;
char *val;
int found_misc = 0;
- static enum minimal_symbol_type types[]
- =
- {mst_data, mst_text, mst_abs, mst_unknown};
- static enum minimal_symbol_type types2[]
- =
- {mst_bss, mst_file_text, mst_abs, mst_unknown};
- static enum minimal_symbol_type types3[]
- =
- {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown};
- static enum minimal_symbol_type types4[]
- =
- {mst_file_bss, mst_text, mst_abs, mst_unknown};
+ static enum minimal_symbol_type types[] =
+ { mst_data, mst_text, mst_abs, mst_unknown };
+ static enum minimal_symbol_type types2[] =
+ { mst_bss, mst_file_text, mst_abs, mst_unknown };
+ static enum minimal_symbol_type types3[] =
+ { mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown };
+ static enum minimal_symbol_type types4[] =
+ { mst_file_bss, mst_text, mst_abs, mst_unknown };
enum minimal_symbol_type ourtype;
enum minimal_symbol_type ourtype2;
enum minimal_symbol_type ourtype3;
if (ps->readin)
continue;
- gbound = objfile->global_psymbols.list + ps->globals_offset + ps->n_global_syms;
- sbound = objfile->static_psymbols.list + ps->statics_offset + ps->n_static_syms;
+ gbound =
+ objfile->global_psymbols.list + ps->globals_offset + ps->n_global_syms;
+ sbound =
+ objfile->static_psymbols.list + ps->statics_offset + ps->n_static_syms;
bound = gbound;
/* Go through all of the symbols stored in a partial
load the file and go on to the next one */
if (file_matches (ps->filename, files, nfiles)
&& ((regexp == NULL || SYMBOL_MATCHES_REGEXP (*psym))
- && ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
- && SYMBOL_CLASS (*psym) != LOC_BLOCK)
- || (kind == FUNCTIONS_NAMESPACE && SYMBOL_CLASS (*psym) == LOC_BLOCK)
- || (kind == TYPES_NAMESPACE && SYMBOL_CLASS (*psym) == LOC_TYPEDEF)
- || (kind == METHODS_NAMESPACE && SYMBOL_CLASS (*psym) == LOC_BLOCK))))
+ &&
+ ((kind == VARIABLES_NAMESPACE
+ && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (*psym) != LOC_BLOCK)
+ || (kind == FUNCTIONS_NAMESPACE
+ && SYMBOL_CLASS (*psym) == LOC_BLOCK)
+ || (kind == TYPES_NAMESPACE
+ && SYMBOL_CLASS (*psym) == LOC_TYPEDEF)
+ || (kind == METHODS_NAMESPACE
+ && SYMBOL_CLASS (*psym) == LOC_BLOCK))))
{
PSYMTAB_TO_SYMTAB (ps);
keep_going = 0;
any matching symbols without debug info.
*/
- if (nfiles == 0 && (kind == VARIABLES_NAMESPACE || kind == FUNCTIONS_NAMESPACE))
+ if (nfiles == 0
+ && (kind == VARIABLES_NAMESPACE || kind == FUNCTIONS_NAMESPACE))
{
ALL_MSYMBOLS (objfile, msymbol)
{
|| lookup_symbol (SYMBOL_NAME (msymbol),
(struct block *) NULL,
VAR_NAMESPACE,
- 0, (struct symtab **) NULL) == NULL)
+ 0, (struct symtab **) NULL) == NULL)
found_misc = 1;
}
}
int nfound = 0;
b = BLOCKVECTOR_BLOCK (bv, i);
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- QUIT;
- if (file_matches (s->filename, files, nfiles)
- && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
- && ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (sym) != LOC_TYPEDEF
- && SYMBOL_CLASS (sym) != LOC_BLOCK
- && SYMBOL_CLASS (sym) != LOC_CONST)
- || (kind == FUNCTIONS_NAMESPACE && SYMBOL_CLASS (sym) == LOC_BLOCK)
- || (kind == TYPES_NAMESPACE && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- || (kind == METHODS_NAMESPACE && SYMBOL_CLASS (sym) == LOC_BLOCK))))
- {
- /* match */
- psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
- psr->block = i;
- psr->symtab = s;
- psr->symbol = sym;
- psr->msymbol = NULL;
- psr->next = NULL;
- if (tail == NULL)
- sr = psr;
- else
- tail->next = psr;
- tail = psr;
- nfound ++;
- }
- }
+ {
+ QUIT;
+ if (file_matches (s->filename, files, nfiles)
+ && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
+ &&
+ ((kind == VARIABLES_NAMESPACE
+ && SYMBOL_CLASS (sym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (sym) != LOC_BLOCK
+ && SYMBOL_CLASS (sym) != LOC_CONST)
+ || (kind == FUNCTIONS_NAMESPACE
+ && SYMBOL_CLASS (sym) == LOC_BLOCK)
+ || (kind == TYPES_NAMESPACE
+ && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ || (kind == METHODS_NAMESPACE
+ && SYMBOL_CLASS (sym) == LOC_BLOCK))))
+ {
+ /* match */
+ psr =
+ (struct symbol_search *)
+ xmalloc (sizeof (struct symbol_search));
+ psr->block = i;
+ psr->symtab = s;
+ psr->symbol = sym;
+ psr->msymbol = NULL;
+ psr->next = NULL;
+ if (tail == NULL)
+ sr = psr;
+ else
+ tail->next = psr;
+ tail = psr;
+ nfound++;
+ }
+ }
if (nfound > 0)
{
if (prevtail == NULL)
0, (struct symtab **) NULL) == NULL)
{
/* match */
- psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
+ psr =
+ (struct symbol_search *)
+ xmalloc (sizeof (struct symbol_search));
psr->block = i;
psr->msymbol = msymbol;
psr->symtab = NULL;
printf_filtered ("static ");
/* Typedef that is not a C++ class */
- if (kind == TYPES_NAMESPACE
- && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE)
+ if (kind == TYPES_NAMESPACE && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE)
typedef_print (SYMBOL_TYPE (sym), sym, gdb_stdout);
/* variable, func, or typedef-that-is-c++-class */
else if (kind < TYPES_NAMESPACE ||
{
type_print (SYMBOL_TYPE (sym),
(SYMBOL_CLASS (sym) == LOC_TYPEDEF
- ? "" : SYMBOL_SOURCE_NAME (sym)),
- gdb_stdout, 0);
+ ? "" : SYMBOL_SOURCE_NAME (sym)), gdb_stdout, 0);
printf_filtered (";\n");
}
#if 0
/* Tiemann says: "info methods was never implemented." */
char *demangled_name;
- c_type_print_base (TYPE_FN_FIELD_TYPE (t, block),
- gdb_stdout, 0, 0);
+ c_type_print_base (TYPE_FN_FIELD_TYPE (t, block), gdb_stdout, 0, 0);
c_type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (t, block),
gdb_stdout, 0);
if (TYPE_FN_FIELD_STUB (t, block))
if (TARGET_ADDR_BIT <= 32)
tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol)
- & (CORE_ADDR) 0xffffffff,
- "08l");
+ & (CORE_ADDR) 0xffffffff, "08l");
else
- tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol),
- "016l");
- printf_filtered ("%s %s\n",
- tmp, SYMBOL_SOURCE_NAME (msymbol));
+ tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol), "016l");
+ printf_filtered ("%s %s\n", tmp, SYMBOL_SOURCE_NAME (msymbol));
}
/* This is the guts of the commands "info functions", "info types", and
static void
symtab_symbol_info (char *regexp, namespace_enum kind, int from_tty)
{
- static char *classnames[]
- =
- {"variable", "function", "type", "method"};
+ static char *classnames[] = { "variable", "function", "type", "method" };
struct symbol_search *symbols;
struct symbol_search *p;
struct cleanup *old_chain;
else
{
print_symbol_info (kind,
- p->symtab,
- p->symbol,
- p->block,
- last_filename);
+ p->symtab, p->symbol, p->block, last_filename);
last_filename = p->symtab->filename;
}
}
break_command (string, from_tty);
print_symbol_info (FUNCTIONS_NAMESPACE,
p->symtab,
- p->symbol,
- p->block,
- p->symtab->filename);
+ p->symbol, p->block, p->symtab->filename);
}
else
{
{
if (!a || !b)
return 0;
- return BLOCK_START (a) >= BLOCK_START (b)
- && BLOCK_END (a) <= BLOCK_END (b);
+ return BLOCK_START (a) >= BLOCK_START (b) && BLOCK_END (a) <= BLOCK_END (b);
}
\f
for (psym = objfile->global_psymbols.list + ps->globals_offset;
psym < (objfile->global_psymbols.list + ps->globals_offset
- + ps->n_global_syms);
- psym++)
+ + ps->n_global_syms); psym++)
{
/* If interrupted, then quit. */
QUIT;
- COMPLETION_LIST_ADD_SYMBOL (*psym, sym_text, sym_text_len, text, word);
+ COMPLETION_LIST_ADD_SYMBOL (*psym, sym_text, sym_text_len, text,
+ word);
}
for (psym = objfile->static_psymbols.list + ps->statics_offset;
psym < (objfile->static_psymbols.list + ps->statics_offset
- + ps->n_static_syms);
- psym++)
+ + ps->n_static_syms); psym++)
{
QUIT;
- COMPLETION_LIST_ADD_SYMBOL (*psym, sym_text, sym_text_len, text, word);
+ COMPLETION_LIST_ADD_SYMBOL (*psym, sym_text, sym_text_len, text,
+ word);
}
}
{
if (!BLOCK_SUPERBLOCK (b))
{
- surrounding_static_block = b; /* For elmin of dups */
+ surrounding_static_block = b; /* For elmin of dups */
}
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
- if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- {
- struct type *t = SYMBOL_TYPE (sym);
- enum type_code c = TYPE_CODE (t);
+ {
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ {
+ struct type *t = SYMBOL_TYPE (sym);
+ enum type_code c = TYPE_CODE (t);
- if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
- {
- for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
- {
- if (TYPE_FIELD_NAME (t, j))
- {
- completion_list_add_name (TYPE_FIELD_NAME (t, j),
- sym_text, sym_text_len, text, word);
- }
- }
- }
- }
- }
+ if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
+ {
+ for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
+ {
+ if (TYPE_FIELD_NAME (t, j))
+ {
+ completion_list_add_name (TYPE_FIELD_NAME (t, j),
+ sym_text, sym_text_len,
+ text, word);
+ }
+ }
+ }
+ }
+ }
}
/* Go through the symtabs and check the externs and statics for
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
- }
+ {
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ }
}
ALL_SYMTABS (objfile, s)
if (b == surrounding_static_block)
continue;
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
- }
+ {
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ }
}
return (return_val);
if (s == NULL)
{
/* Maybe they typed the file with leading directories, while the
- symbol tables record only its basename. */
+ symbol tables record only its basename. */
const char *tail = lbasename (srcfile);
if (tail > srcfile)
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
- }
+ {
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ }
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
- }
+ {
+ COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
+ }
return (return_val);
}
not_interesting_fname (const char *fname)
{
static const char *illegal_aliens[] = {
- "_globals_", /* inserted by coff_symtab_read */
+ "_globals_", /* inserted by coff_symtab_read */
NULL
};
int i;
return list;
ALL_SYMTABS (objfile, s)
- {
- if (not_interesting_fname (s->filename))
- continue;
- if (!filename_seen (s->filename, 1, &first)
+ {
+ if (not_interesting_fname (s->filename))
+ continue;
+ if (!filename_seen (s->filename, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
- && strncasecmp (s->filename, text, text_len) == 0
+ && strncasecmp (s->filename, text, text_len) == 0
#else
- && strncmp (s->filename, text, text_len) == 0
+ && strncmp (s->filename, text, text_len) == 0
#endif
- )
- {
- /* This file matches for a completion; add it to the current
- list of matches. */
- add_filename_to_list (s->filename, text, word,
- &list, &list_used, &list_alloced);
- }
- else
- {
- /* NOTE: We allow the user to type a base name when the
- debug info records leading directories, but not the other
- way around. This is what subroutines of breakpoint
- command do when they parse file names. */
- base_name = lbasename (s->filename);
- if (base_name != s->filename
- && !filename_seen (base_name, 1, &first)
+ )
+ {
+ /* This file matches for a completion; add it to the current
+ list of matches. */
+ add_filename_to_list (s->filename, text, word,
+ &list, &list_used, &list_alloced);
+ }
+ else
+ {
+ /* NOTE: We allow the user to type a base name when the
+ debug info records leading directories, but not the other
+ way around. This is what subroutines of breakpoint
+ command do when they parse file names. */
+ base_name = lbasename (s->filename);
+ if (base_name != s->filename && !filename_seen (base_name, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
- && strncasecmp (base_name, text, text_len) == 0
+ && strncasecmp (base_name, text, text_len) == 0
#else
- && strncmp (base_name, text, text_len) == 0
+ && strncmp (base_name, text, text_len) == 0
#endif
- )
- add_filename_to_list (base_name, text, word,
- &list, &list_used, &list_alloced);
- }
- }
+ )
+ add_filename_to_list (base_name, text, word,
+ &list, &list_used, &list_alloced);
+ }
+ }
ALL_PSYMTABS (objfile, ps)
- {
- if (not_interesting_fname (ps->filename))
- continue;
- if (!ps->readin)
- {
- if (!filename_seen (ps->filename, 1, &first)
+ {
+ if (not_interesting_fname (ps->filename))
+ continue;
+ if (!ps->readin)
+ {
+ if (!filename_seen (ps->filename, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
- && strncasecmp (ps->filename, text, text_len) == 0
+ && strncasecmp (ps->filename, text, text_len) == 0
#else
- && strncmp (ps->filename, text, text_len) == 0
+ && strncmp (ps->filename, text, text_len) == 0
#endif
- )
- {
- /* This file matches for a completion; add it to the
- current list of matches. */
- add_filename_to_list (ps->filename, text, word,
- &list, &list_used, &list_alloced);
+ )
+ {
+ /* This file matches for a completion; add it to the
+ current list of matches. */
+ add_filename_to_list (ps->filename, text, word,
+ &list, &list_used, &list_alloced);
- }
- else
- {
- base_name = lbasename (ps->filename);
- if (base_name != ps->filename
- && !filename_seen (base_name, 1, &first)
+ }
+ else
+ {
+ base_name = lbasename (ps->filename);
+ if (base_name != ps->filename
+ && !filename_seen (base_name, 1, &first)
#if HAVE_DOS_BASED_FILE_SYSTEM
- && strncasecmp (base_name, text, text_len) == 0
+ && strncasecmp (base_name, text, text_len) == 0
#else
- && strncmp (base_name, text, text_len) == 0
+ && strncmp (base_name, text, text_len) == 0
#endif
- )
- add_filename_to_list (base_name, text, word,
- &list, &list_used, &list_alloced);
- }
- }
- }
+ )
+ add_filename_to_list (base_name, text, word,
+ &list, &list_used, &list_alloced);
+ }
+ }
+ }
return list;
}
/* 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.
+ 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.
+ us the starting and ending addresses of a function.
- If we know the function's start address, we can call the
- architecture-defined SKIP_PROLOGUE function to analyze the
- instruction stream and guess where the prologue ends.
+ architecture-defined 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. */
+ 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))
+ 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)
+ if (!func_start)
return 1; /* We *might* be in a prologue. */
prologue_end = SKIP_PROLOGUE (func_start);
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)
+ 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. */
+ information, together with the architecture-specific prologue
+ scanning code. */
CORE_ADDR prologue_end = SKIP_PROLOGUE (func_addr);
return func_addr <= pc && pc < prologue_end;
while (argp-- > demangled_name)
{
if (*argp == ')')
- depth ++;
+ depth++;
else if (*argp == '(')
{
- depth --;
+ depth--;
if (depth == 0)
break;
internal_error (__FILE__, __LINE__,
"bad demangled name %s\n", demangled_name);
while (argp[-1] == ' ' && argp > demangled_name)
- argp --;
+ argp--;
new_name = xmalloc (argp - demangled_name + 1);
memcpy (new_name, demangled_name, argp - demangled_name);
if (sym_return_val_index + 3 > sym_return_val_size)
{
newsize = (sym_return_val_size *= 2) * sizeof (struct symbol *);
- sym_return_val = (struct symbol **) xrealloc ((char *) sym_return_val, newsize);
+ sym_return_val =
+ (struct symbol **) xrealloc ((char *) sym_return_val, newsize);
}
sym_return_val[sym_return_val_index++] = sym;
sym_return_val[sym_return_val_index] = NULL;
if (!oload_name)
{
sym_return_val_size = 1;
- sym_return_val = (struct symbol **) xmalloc (2 * sizeof (struct symbol *));
+ sym_return_val =
+ (struct symbol **) xmalloc (2 * sizeof (struct symbol *));
sym_return_val[0] = fsym;
sym_return_val[1] = NULL;
sym_return_val_size = 100;
sym_return_val_index = 0;
- sym_return_val = (struct symbol **) xmalloc ((sym_return_val_size + 1) * sizeof (struct symbol *));
+ sym_return_val =
+ (struct symbol **) xmalloc ((sym_return_val_size + 1) *
+ sizeof (struct symbol *));
sym_return_val[0] = NULL;
/* Look through the partial symtabs for all symbols which begin
for (psym = objfile->global_psymbols.list + ps->globals_offset;
psym < (objfile->global_psymbols.list + ps->globals_offset
- + ps->n_global_syms);
- psym++)
+ + ps->n_global_syms); psym++)
{
/* If interrupted, then quit. */
QUIT;
- /* This will cause the symbol table to be read if it has not yet been */
- s = PSYMTAB_TO_SYMTAB (ps);
+ /* This will cause the symbol table to be read if it has not yet been */
+ s = PSYMTAB_TO_SYMTAB (ps);
}
for (psym = objfile->static_psymbols.list + ps->statics_offset;
psym < (objfile->static_psymbols.list + ps->statics_offset
- + ps->n_static_syms);
- psym++)
+ + ps->n_static_syms); psym++)
{
QUIT;
- /* This will cause the symbol table to be read if it has not yet been */
- s = PSYMTAB_TO_SYMTAB (ps);
+ /* This will cause the symbol table to be read if it has not yet been */
+ s = PSYMTAB_TO_SYMTAB (ps);
}
}
{
if (!BLOCK_SUPERBLOCK (b))
{
- surrounding_static_block = b; /* For elimination of dups */
+ surrounding_static_block = b; /* For elimination of dups */
}
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- overload_list_add_symbol (sym, oload_name);
- }
+ {
+ overload_list_add_symbol (sym, oload_name);
+ }
}
/* Go through the symtabs and check the externs and statics for
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- overload_list_add_symbol (sym, oload_name);
- }
+ {
+ overload_list_add_symbol (sym, oload_name);
+ }
}
ALL_SYMTABS (objfile, s)
if (b == surrounding_static_block)
continue;
ALL_BLOCK_SYMBOLS (b, iter, sym)
- {
- overload_list_add_symbol (sym, oload_name);
- }
+ {
+ overload_list_add_symbol (sym, oload_name);
+ }
}
xfree (oload_name);
{
struct symtabs_and_lines sals;
struct symtab_and_line cursal;
-
+
if (string == 0)
error ("Empty line specification.");
-
+
/* We use whatever is set as the current source line. We do not try
- and get a default or it will recursively call us! */
+ and get a default or it will recursively call us! */
cursal = get_current_source_symtab_and_line ();
-
+
sals = decode_line_1 (&string, funfirstline,
- cursal.symtab, cursal.line,
- (char ***) NULL);
+ cursal.symtab, cursal.line, (char ***) NULL);
if (*string)
error ("Junk at end of line specification: %s", string);
_initialize_symtab (void)
{
add_info ("variables", variables_info,
- "All global and static variable names, or those matching REGEXP.");
+ "All global and static variable names, or those matching REGEXP.");
if (dbx_commands)
add_com ("whereis", class_info, variables_info,
- "All global and static variable names, or those matching REGEXP.");
+ "All global and static variable names, or those matching REGEXP.");
add_info ("functions", functions_info,
"All function names, or those matching REGEXP.");
-
+
/* FIXME: This command has at least the following problems:
1. It prints builtin types (in a very strange and confusing fashion).
2. It doesn't print right, e.g. with
print "struct foo *".
I also think "ptype" or "whatis" is more likely to be useful (but if
there is much disagreement "info types" can be fixed). */
- add_info ("types", types_info,
- "All type names, or those matching REGEXP.");
+ add_info ("types", types_info, "All type names, or those matching REGEXP.");
#if 0
add_info ("methods", methods_info,
If the first REGEXP is omitted, then all methods matching the second REGEXP\n\
are listed.");
#endif
- add_info ("sources", sources_info,
- "Source files in the program.");
+ add_info ("sources", sources_info, "Source files in the program.");
add_com ("rbreak", class_breakpoint, rbreak_command,
"Set a breakpoint for all functions matching REGEXP.");
{
add_com ("lf", class_info, sources_info, "Source files in the program");
add_com ("lg", class_info, variables_info,
- "All global and static variable names, or those matching REGEXP.");
+ "All global and static variable names, or those matching REGEXP.");
}
/* Initialize the one built-in type that isn't language dependent... */