/* Symbol table definitions for GDB.
- Copyright (C) 1986-2014 Free Software Foundation, Inc.
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
This file is part of GDB.
struct language_defn;
struct probe;
struct common_block;
+struct obj_section;
+struct cmd_list_element;
/* Some of the structures in this file are space critical.
The space-critical structures are:
COMMON_BLOCK_DOMAIN
} domain_enum;
+/* The number of bits in a symbol used to represent the domain. */
+
+#define SYMBOL_DOMAIN_BITS 4
+
extern const char *domain_name (domain_enum);
/* Searching domains, used for `search_symbols'. Element numbers are
struct type *type;
- /* The symbol table containing this symbol. This is the file
- associated with LINE. It can be NULL during symbols read-in but it is
- never NULL during normal operation. */
- struct symtab *symtab;
+ /* The owner of this symbol.
+ Which one to use is defined by symbol.is_objfile_owned. */
+
+ union
+ {
+ /* The symbol table containing this symbol. This is the file associated
+ with LINE. It can be NULL during symbols read-in but it is never NULL
+ during normal operation. */
+ struct symtab *symtab;
+
+ /* For types defined by the architecture. */
+ struct gdbarch *arch;
+ } owner;
/* Domain code. */
- ENUM_BITFIELD(domain_enum_tag) domain : 6;
+ ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS;
/* Address class. This holds an index into the 'symbol_impls'
table. The actual enum address_class value is stored there,
unsigned int aclass_index : SYMBOL_ACLASS_BITS;
+ /* If non-zero then symbol is objfile-owned, use owner.symtab.
+ Otherwise symbol is arch-owned, use owner.arch. */
+
+ unsigned int is_objfile_owned : 1;
+
/* Whether this is an argument. */
unsigned is_argument : 1;
SYMBOL_INLINED set) this is the line number of the function's call
site. Inlined function symbols are not definitions, and they are
never found by symbol table lookup.
+ If this symbol is arch-owned, LINE shall be zero.
FIXME: Should we really make the assumption that nobody will try
to debug files longer than 64K lines? What about machine
struct symbol *hash_next;
};
+/* Several lookup functions return both a symbol and the block in which the
+ symbol is found. This structure is used in these cases. */
+
+struct block_symbol
+{
+ /* The symbol that was found, or NULL if no symbol was found. */
+ struct symbol *symbol;
+
+ /* If SYMBOL is not NULL, then this is the block in which the symbol is
+ defined. */
+ const struct block *block;
+};
+
extern const struct symbol_impl *symbol_impls;
+/* Note: There is no accessor macro for symbol.owner because it is
+ "private". */
+
#define SYMBOL_DOMAIN(symbol) (symbol)->domain
#define SYMBOL_IMPL(symbol) (symbol_impls[(symbol)->aclass_index])
#define SYMBOL_ACLASS_INDEX(symbol) (symbol)->aclass_index
#define SYMBOL_CLASS(symbol) (SYMBOL_IMPL (symbol).aclass)
+#define SYMBOL_OBJFILE_OWNED(symbol) ((symbol)->is_objfile_owned)
#define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument
#define SYMBOL_INLINED(symbol) (symbol)->is_inlined
#define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
(symbol)->is_cplus_template_function
#define SYMBOL_TYPE(symbol) (symbol)->type
#define SYMBOL_LINE(symbol) (symbol)->line
-#define SYMBOL_SYMTAB(symbol) (symbol)->symtab
#define SYMBOL_COMPUTED_OPS(symbol) (SYMBOL_IMPL (symbol).ops_computed)
#define SYMBOL_BLOCK_OPS(symbol) (SYMBOL_IMPL (symbol).ops_block)
#define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register)
#define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value
-#define SYMBOL_OBJFILE(symbol) SYMTAB_OBJFILE (SYMBOL_SYMTAB (symbol))
extern int register_symbol_computed_impl (enum address_class,
const struct symbol_computed_ops *);
extern int register_symbol_register_impl (enum address_class,
const struct symbol_register_ops *);
+/* Return the OBJFILE of SYMBOL.
+ It is an error to call this if symbol.is_objfile_owned is false, which
+ only happens for architecture-provided types. */
+
+extern struct objfile *symbol_objfile (const struct symbol *symbol);
+
+/* Return the ARCH of SYMBOL. */
+
+extern struct gdbarch *symbol_arch (const struct symbol *symbol);
+
+/* Return the SYMTAB of SYMBOL.
+ It is an error to call this if symbol.is_objfile_owned is false, which
+ only happens for architecture-provided types. */
+
+extern struct symtab *symbol_symtab (const struct symbol *symbol);
+
+/* Set the symtab of SYMBOL to SYMTAB.
+ It is an error to call this if symbol.is_objfile_owned is false, which
+ only happens for architecture-provided types. */
+
+extern void symbol_set_symtab (struct symbol *symbol, struct symtab *symtab);
+
/* An instance of this type is used to represent a C++ template
function. It includes a "struct symbol" as a kind of base class;
users downcast to "struct template_symbol *" when needed. A symbol
struct symtab
{
- /* Unordered chain of all existing symtabs of this objfile. */
+ /* Unordered chain of all filetabs in the compunit, with the exception
+ that the "main" source file is the first entry in the list. */
struct symtab *next;
extern int currently_reading_symtab;
-/* The block in which the most recently looked up symbol was found. */
-
-extern const struct block *block_found;
-
/* symtab.c lookup functions */
extern const char multiple_symbols_ask[];
C++: if IS_A_FIELD_OF_THIS is non-NULL on entry, check to see if
NAME is a field of the current implied argument `this'. If so fill in the
fields of IS_A_FIELD_OF_THIS, otherwise the fields are set to NULL.
- 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).
The symbol's section is fixed up if necessary. */
-extern struct symbol *lookup_symbol_in_language (const char *,
- const struct block *,
- const domain_enum,
- enum language,
- struct field_of_this_result *);
+extern struct block_symbol
+ lookup_symbol_in_language (const char *,
+ const struct block *,
+ const domain_enum,
+ enum language,
+ struct field_of_this_result *);
/* Same as lookup_symbol_in_language, but using the current language. */
-extern struct symbol *lookup_symbol (const char *, const struct block *,
- const domain_enum,
- struct field_of_this_result *);
+extern struct block_symbol lookup_symbol (const char *,
+ const struct block *,
+ const domain_enum,
+ struct field_of_this_result *);
/* A default version of lookup_symbol_nonlocal for use by languages
that can't think of anything better to do.
This implements the C lookup rules. */
-extern struct symbol *basic_lookup_symbol_nonlocal (const char *,
- const struct block *,
- const domain_enum);
+extern struct block_symbol
+ basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
+ const char *,
+ const struct block *,
+ const domain_enum);
/* Some helper functions for languages that need to write their own
lookup_symbol_nonlocal functions. */
/* Lookup a symbol in the static block associated to BLOCK, if there
is one; do nothing if BLOCK is NULL or a global block.
- Upon success sets BLOCK_FOUND and fixes up the symbol's section
- if necessary. */
+ Upon success fixes up the symbol's section if necessary. */
-extern struct symbol *lookup_symbol_in_static_block (const char *name,
- const struct block *block,
- const domain_enum domain);
+extern struct block_symbol
+ lookup_symbol_in_static_block (const char *name,
+ const struct block *block,
+ const domain_enum domain);
/* Search all static file-level symbols for NAME from DOMAIN.
- Upon success sets BLOCK_FOUND and fixes up the symbol's section
- if necessary. */
+ Upon success fixes up the symbol's section if necessary. */
-extern struct symbol *lookup_static_symbol (const char *name,
- const domain_enum domain);
+extern struct block_symbol lookup_static_symbol (const char *name,
+ const domain_enum domain);
/* Lookup a symbol in all files' global blocks.
if the target requires it.
See gdbarch_iterate_over_objfiles_in_search_order.
- Upon success sets BLOCK_FOUND and fixes up the symbol's section
- if necessary. */
+ Upon success fixes up the symbol's section if necessary. */
-extern struct symbol *lookup_global_symbol (const char *name,
- const struct block *block,
- const domain_enum domain);
+extern struct block_symbol
+ lookup_global_symbol (const char *name,
+ const struct block *block,
+ const domain_enum domain);
/* Lookup a symbol in block BLOCK.
- Upon success sets BLOCK_FOUND and fixes up the symbol's section
- if necessary. */
+ Upon success fixes up the symbol's section if necessary. */
-extern struct symbol *lookup_symbol_in_block (const char *name,
- const struct block *block,
- const domain_enum domain);
+extern struct symbol *
+ lookup_symbol_in_block (const char *name,
+ const struct block *block,
+ const domain_enum domain);
/* Look up the `this' symbol for LANG in BLOCK. Return the symbol if
found, or NULL if not found. */
-extern struct symbol *lookup_language_this (const struct language_defn *lang,
- const struct block *block);
+extern struct block_symbol
+ lookup_language_this (const struct language_defn *lang,
+ const struct block *block);
/* Lookup a [struct, union, enum] by name, within a specified block. */
extern void resolve_sal_pc (struct symtab_and_line *);
-/* Symbol-reading stuff in symfile.c and solib.c. */
+/* solib.c */
extern void clear_solib (void);
extern void skip_prologue_sal (struct symtab_and_line *);
-/* symfile.c */
-
-extern void clear_symtab_users (int add_flags);
-
-extern enum language deduce_language_from_filename (const char *);
-
/* symtab.c */
extern CORE_ADDR skip_prologue_using_sal (struct gdbarch *gdbarch,
/* Information describing what was found.
- If symtab and symbol are NOT NULL, then information was found
- for this match. */
- struct symtab *symtab;
+ If symbol is NOT NULL, then information was found for this match. */
struct symbol *symbol;
/* If msymbol is non-null, then a match was made on something for
/* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.
This searches MAIN_OBJFILE as well as any associated separate debug info
objfiles of MAIN_OBJFILE.
- Upon success sets BLOCK_FOUND and fixes up the symbol's section
- if necessary. */
+ Upon success fixes up the symbol's section if necessary. */
-extern struct symbol *
+extern struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
const char *name,
const domain_enum domain);
extern unsigned int symtab_create_debug;
+extern unsigned int symbol_lookup_debug;
+
extern int basenames_may_differ;
int compare_filenames_for_search (const char *filename,
struct symbol *allocate_symbol (struct objfile *);
-void initialize_symbol (struct symbol *);
+void initialize_objfile_symbol (struct symbol *);
struct template_symbol *allocate_template_symbol (struct objfile *);