const struct block *block,
const domain_enum domain,
enum language language,
- int *is_a_field_of_this);
+ int *is_a_field_of_this,
+ int for_type);
static
struct symbol *lookup_symbol_aux_local (const char *name,
return (mangled_name);
}
+/* Initialize the cplus_specific structure. 'cplus_specific' should
+ only be allocated for use with cplus symbols. */
+
+static void
+symbol_init_cplus_specific (struct general_symbol_info *gsymbol,
+ struct objfile *objfile)
+{
+ /* A language_specific structure should not have been previously
+ initialized. */
+ gdb_assert (gsymbol->language_specific.cplus_specific == NULL);
+ gdb_assert (objfile != NULL);
+
+ gsymbol->language_specific.cplus_specific =
+ OBSTACK_ZALLOC (&objfile->objfile_obstack, struct cplus_specific);
+}
+
+/* Set the demangled name of GSYMBOL to NAME. NAME must be already
+ correctly allocated. For C++ symbols a cplus_specific struct is
+ allocated so OBJFILE must not be NULL. If this is a non C++ symbol
+ OBJFILE can be NULL. */
+void
+symbol_set_demangled_name (struct general_symbol_info *gsymbol,
+ char *name,
+ struct objfile *objfile)
+{
+ if (gsymbol->language == language_cplus)
+ {
+ if (gsymbol->language_specific.cplus_specific == NULL)
+ symbol_init_cplus_specific (gsymbol, objfile);
+
+ gsymbol->language_specific.cplus_specific->demangled_name = name;
+ }
+ else
+ gsymbol->language_specific.mangled_lang.demangled_name = name;
+}
+
+/* Return the demangled name of GSYMBOL. */
+char *
+symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
+{
+ if (gsymbol->language == language_cplus)
+ {
+ if (gsymbol->language_specific.cplus_specific != NULL)
+ return gsymbol->language_specific.cplus_specific->demangled_name;
+ else
+ return NULL;
+ }
+ else
+ return gsymbol->language_specific.mangled_lang.demangled_name;
+}
+
\f
/* Initialize the language dependent portion of a symbol
depending upon the language for the symbol. */
void
-symbol_init_language_specific (struct general_symbol_info *gsymbol,
- enum language language)
+symbol_set_language (struct general_symbol_info *gsymbol,
+ enum language language)
{
gsymbol->language = language;
- if (gsymbol->language == language_cplus
- || gsymbol->language == language_d
+ if (gsymbol->language == language_d
|| gsymbol->language == language_java
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
{
- gsymbol->language_specific.mangled_lang.demangled_name = NULL;
+ symbol_set_demangled_name (gsymbol, NULL, NULL);
}
+ else if (gsymbol->language == language_cplus)
+ gsymbol->language_specific.cplus_specific = NULL;
else
{
memset (&gsymbol->language_specific, 0,
memcpy (gsymbol->name, linkage_name, len);
gsymbol->name[len] = '\0';
}
- gsymbol->language_specific.mangled_lang.demangled_name = NULL;
+ symbol_set_demangled_name (gsymbol, NULL, NULL);
return;
}
gsymbol->name = (*slot)->mangled + lookup_len - len;
if ((*slot)->demangled[0] != '\0')
- gsymbol->language_specific.mangled_lang.demangled_name
- = (*slot)->demangled;
+ symbol_set_demangled_name (gsymbol, (*slot)->demangled, objfile);
else
- gsymbol->language_specific.mangled_lang.demangled_name = NULL;
+ symbol_set_demangled_name (gsymbol, NULL, objfile);
}
/* Return the source code name of a symbol. In languages where
case language_java:
case language_objc:
case language_fortran:
- if (gsymbol->language_specific.mangled_lang.demangled_name != NULL)
- return gsymbol->language_specific.mangled_lang.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
break;
case language_ada:
- if (gsymbol->language_specific.mangled_lang.demangled_name != NULL)
- return gsymbol->language_specific.mangled_lang.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
else
return ada_decode_symbol (gsymbol);
break;
case language_java:
case language_objc:
case language_fortran:
- if (gsymbol->language_specific.mangled_lang.demangled_name != NULL)
- return gsymbol->language_specific.mangled_lang.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
break;
case language_ada:
- if (gsymbol->language_specific.mangled_lang.demangled_name != NULL)
- return gsymbol->language_specific.mangled_lang.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
else
return ada_decode_symbol (gsymbol);
break;
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.
+ FOR_TYPE is non-zero if searching specifically for a type; zero
+ otherwise.
BLOCK_FOUND is set to the block in which NAME is found (in the case of
a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */
variable and thus can probably assume it will never hit the C++
code). */
-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)
+static struct symbol *
+lookup_symbol_in_language_full (const char *name, const struct block *block,
+ const domain_enum domain, enum language lang,
+ int *is_a_field_of_this, int for_type)
{
char *demangled_name = NULL;
const char *modified_name = NULL;
}
returnval = lookup_symbol_aux (modified_name, block, domain, lang,
- is_a_field_of_this);
+ is_a_field_of_this, for_type);
do_cleanups (cleanup);
return returnval;
}
+/* 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.
+ 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.
+ BLOCK_FOUND is set to the block in which NAME is found (in the case of
+ a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */
+
+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)
+{
+ return lookup_symbol_in_language_full (name, block, domain, lang,
+ is_a_field_of_this, 0);
+}
+
+/* Like lookup_symbol_in_language, but search specifically for a
+ type. */
+
+struct symbol *
+lookup_type_symbol (const char *name, const struct block *block,
+ const domain_enum domain, enum language lang)
+{
+ return lookup_symbol_in_language_full (name, block, domain, lang,
+ NULL, 1);
+}
+
/* Behave like lookup_symbol_in_language, but performed with the
current language. */
static struct symbol *
lookup_symbol_aux (const char *name, const struct block *block,
const domain_enum domain, enum language language,
- int *is_a_field_of_this)
+ int *is_a_field_of_this,
+ int for_type)
{
struct symbol *sym;
const struct language_defn *langdef;
}
/* Now do whatever is appropriate for LANGUAGE to look
- up static and global variables. */
+ up static and global variables. If we are searching for a type,
+ we bypass this lookup, because types aren't global. */
- sym = langdef->la_lookup_symbol_nonlocal (name, block, domain);
- if (sym != NULL)
- return sym;
+ if (!for_type)
+ {
+ sym = langdef->la_lookup_symbol_nonlocal (name, block, domain);
+ if (sym != NULL)
+ return sym;
+ }
- /* Now search all static file-level symbols. Not strictly correct,
- but more useful than an error. */
+ /* Now search all static file-level symbols. When searching for a
+ type, this is what we generally want, because types are put into
+ the file scope. For other objects, not strictly correct, but
+ more useful than an error. */
return lookup_static_symbol_aux (name, domain);
}
if (language == language_cplus || language == language_fortran)
{
- sym = cp_lookup_symbol_imports (scope,
- name,
- block,
- domain,
- 1,
- 1);
+ sym = cp_lookup_symbol_imports_or_template (scope, name, block,
+ domain);
if (sym != NULL)
return sym;
}
return NULL;
}
+/* A helper for lookup_symbol_aux_symtabs that is passed as a callback
+ to the expand_one_symtab_matching quick function. */
+
+static struct symbol *
+match_symbol_aux (struct symtab *symtab,
+ int kind, const char *name, domain_enum domain,
+ void *arg)
+{
+ struct objfile *objfile = arg;
+
+ if (symtab->primary)
+ {
+ struct symbol *sym;
+ struct blockvector *bv;
+ const struct block *block;
+
+ bv = BLOCKVECTOR (symtab);
+ block = BLOCKVECTOR_BLOCK (bv, kind);
+ sym = lookup_block_symbol (block, name, domain);
+ if (sym)
+ {
+ block_found = block;
+ return fixup_symbol_section (sym, objfile);
+ }
+ }
+
+ return NULL;
+}
+
/* 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
ALL_OBJFILES (objfile)
{
- if (objfile->sf)
- objfile->sf->qf->pre_expand_symtabs_matching (objfile,
- block_index,
- name, domain);
-
ALL_OBJFILE_SYMTABS (objfile, s)
if (s->primary)
{
return fixup_symbol_section (sym, objfile);
}
}
+
+ if (objfile->sf)
+ {
+ sym = objfile->sf->qf->expand_one_symtab_matching (objfile,
+ block_index,
+ name, domain,
+ match_symbol_aux,
+ objfile);
+ if (sym)
+ return sym;
+ }
}
return NULL;
return NULL;
}
+/* A helper function for basic_lookup_transparent_type that is passed
+ to the expand_one_symtab_matching quick function. */
+
+static struct symbol *
+match_transparent_type (struct symtab *symtab,
+ int kind, const char *name, domain_enum domain,
+ void *data)
+{
+ if (symtab->primary)
+ {
+ struct blockvector *bv;
+ struct block *block;
+ struct symbol *sym;
+
+ bv = BLOCKVECTOR (symtab);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+ if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ return sym;
+ }
+
+ return NULL;
+}
+
/* The standard implementation of lookup_transparent_type. This code
was modeled on lookup_symbol -- the parts not relevant to looking
up types were just left out. In particular it's assumed here that
ALL_OBJFILES (objfile)
{
- if (objfile->sf)
- objfile->sf->qf->pre_expand_symtabs_matching (objfile,
- GLOBAL_BLOCK,
- name, STRUCT_DOMAIN);
-
ALL_OBJFILE_SYMTABS (objfile, s)
if (s->primary)
{
return SYMBOL_TYPE (sym);
}
}
+
+ if (objfile->sf)
+ {
+ sym
+ = objfile->sf->qf->expand_one_symtab_matching (objfile,
+ GLOBAL_BLOCK, name,
+ STRUCT_DOMAIN,
+ match_transparent_type,
+ NULL);
+ if (sym)
+ return SYMBOL_TYPE (sym);
+ }
}
ALL_OBJFILES (objfile)
conversion on the fly and return the found symbol.
*/
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILES (objfile)
{
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ ALL_OBJFILE_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+ if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ {
+ return SYMBOL_TYPE (sym);
+ }
+ }
+
+ if (objfile->sf)
{
- return SYMBOL_TYPE (sym);
+ sym
+ = objfile->sf->qf->expand_one_symtab_matching (objfile,
+ STATIC_BLOCK, name,
+ STRUCT_DOMAIN,
+ match_transparent_type,
+ NULL);
+ if (sym)
+ return SYMBOL_TYPE (sym);
}
}
struct minimal_symbol *msymbol;
char *val;
int found_misc = 0;
- static enum minimal_symbol_type types[]
+ static const enum minimal_symbol_type types[]
= {mst_data, mst_text, mst_abs, mst_unknown};
- static enum minimal_symbol_type types2[]
+ static const enum minimal_symbol_type types2[]
= {mst_bss, mst_file_text, mst_abs, mst_unknown};
- static enum minimal_symbol_type types3[]
+ static const enum minimal_symbol_type types3[]
= {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown};
- static enum minimal_symbol_type types4[]
+ static const enum minimal_symbol_type types4[]
= {mst_file_bss, mst_text, mst_abs, mst_unknown};
enum minimal_symbol_type ourtype;
enum minimal_symbol_type ourtype2;
static void
symtab_symbol_info (char *regexp, domain_enum kind, int from_tty)
{
- static char *classnames[] = {"variable", "function", "type", "method"};
+ static const char * const classnames[] =
+ {"variable", "function", "type", "method"};
struct symbol_search *symbols;
struct symbol_search *p;
struct cleanup *old_chain;
/* A callback for map_partial_symbol_filenames. */
static void
-maybe_add_partial_symtab_filename (const char *fullname, const char *filename,
+maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
void *user_data)
{
struct add_partial_filename_data *data = user_data;