From e7cc50c8ea958cb295ac975e265e558d7539c055 Mon Sep 17 00:00:00 2001 From: David Carlton Date: Tue, 8 Oct 2002 00:12:23 +0000 Subject: [PATCH] 2002-10-07 David Carlton * buildsym.c (finish_block): Initialize BLOCK_USING to NULL. * symtab.h (struct block): Delete last remnants of non-dictionary symbol lists. (struct block): Add field 'language_specific' and accessor macro BLOCK_USING. * cp-support.h (struct using_data): New struct. (struct using_data_node): New struct. --- gdb/ChangeLog | 10 +++++++ gdb/buildsym.c | 1 + gdb/cp-support.h | 31 ++++++++++++++++++++ gdb/symtab.c | 26 ++++++++--------- gdb/symtab.h | 75 ++++++++++-------------------------------------- 5 files changed, 70 insertions(+), 73 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fa85187a713..da709ab836a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2002-10-07 David Carlton + + * buildsym.c (finish_block): Initialize BLOCK_USING to NULL. + * symtab.h (struct block): Delete last remnants of non-dictionary + symbol lists. + (struct block): Add field 'language_specific' and accessor macro + BLOCK_USING. + * cp-support.h (struct using_data): New struct. + (struct using_data_node): New struct. + 2002-09-30 David Carlton * dictionary.h: Augment comment above dict_lookup. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index bbb1cc23956..3da29f81c20 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -257,6 +257,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, BLOCK_END (block) = end; /* Superblock filled in when containing block is made */ BLOCK_SUPERBLOCK (block) = NULL; + BLOCK_USING (block) = NULL; BLOCK_GCC_COMPILED (block) = processing_gcc_compilation; diff --git a/gdb/cp-support.h b/gdb/cp-support.h index a7d333f28b2..11f7b0a58f2 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -23,3 +23,34 @@ extern char *class_name_from_physname (const char *physname); extern char *method_name_from_physname (const char *physname); + +/* This is a struct to store data from "using directives" and similar + language constructs. It contains two strings, OLD and NEW; both + should be fully-qualified namespace names, NEW should be an initial + substring of OLD, and it says that names in the namespace OLD + should be imported into namespace NEW. For example, if it is used + to represent the directive "using namespace std;" then OLD should + be "std" and new should be "". For a more complicated example, if + there is an anonymous namespace with a named namespace A, then OLD + should be "A::(anonymous namespace)" and new should be "A". */ + +/* FIXME: carlton/2002-10-07: That anonymous namespace example isn't + that great, since it really depends not only on what the + demangler's output is but also on the fact that the demangler's + output doesn't depend on the name of the file in question. Which, + alas, it doesn't, but should, leaving us with no way to distinguish + between anonymous namespaces in different files. Sigh... */ + +struct using_data +{ + const char *old; + const char *new; +}; + +/* This is a struct for a linked list of using_data's. */ + +struct using_data_node +{ + struct using_data *current; + struct using_data_node *next; +}; diff --git a/gdb/symtab.c b/gdb/symtab.c index bb6879e6e17..c3485b56001 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -103,18 +103,18 @@ struct symbol *lookup_symbol_aux_symtabs (int block_index, 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 *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); @@ -800,8 +800,8 @@ lookup_symbol_aux (const char *name, const char *mangled_name, way. */ sym = lookup_symbol_aux_minsyms (name, mangled_name, - namespace, is_a_field_of_this, - symtab); + namespace, is_a_field_of_this, + symtab); if (sym != NULL) return sym; @@ -843,8 +843,8 @@ lookup_symbol_aux (const char *name, const char *mangled_name, before the static check in this case? */ sym = lookup_symbol_aux_minsyms (name, mangled_name, - namespace, is_a_field_of_this, - symtab); + namespace, is_a_field_of_this, + symtab); if (sym != NULL) return sym; @@ -903,7 +903,7 @@ lookup_symbol_aux_local (const char *name, const char *mangled_name, /* 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. */ + static symbols. */ static struct symbol * lookup_symbol_aux_symtabs (int block_index, @@ -937,7 +937,7 @@ lookup_symbol_aux_symtabs (int block_index, /* 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. */ + symbols or static symbols. */ static struct symbol * lookup_symbol_aux_psymtabs (int block_index, const char *name, @@ -972,7 +972,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name, /* 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 + silently dealing with it here? So I'd vote for removing the check for the symbol in the other block. */ block = BLOCKVECTOR_BLOCK (bv, diff --git a/gdb/symtab.h b/gdb/symtab.h index 4a5186761d2..d73fc2439ec 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -26,6 +26,7 @@ /* Opaque declarations. */ struct obstack; struct dictionary; +struct using_data_node; /* Don't do this; it means that if some .o's are compiled with GNU C and some are not (easy to do accidentally the way we configure @@ -398,6 +399,19 @@ struct block struct dictionary *dict; + /* Used for language-specific info. */ + union + { + struct + { + /* Contains information about what using directives or other + similar features are added by this block. */ + struct using_data_node *using; + } + cplus_specific; + } + language_specific; + /* Version of GCC used to compile the function corresponding to this block, or 0 if not compiled with GCC. When possible, GCC should be compatible with the native compiler, or if that @@ -409,39 +423,6 @@ struct block of this flag is undefined. */ unsigned char gcc_compile_flag; - - /* The symbols for this block are either in a simple linear list or - in a simple hashtable. Blocks which correspond to a function - (which have a list of symbols corresponding to arguments) use - a linear list, as do some older symbol readers (currently only - mdebugread and dstread). Other blocks are hashed. - - The hashtable uses the same hash function as the minsym hashtables, - found in minsyms.c:minsym_hash_iw. Symbols are hashed based on - their demangled name if appropriate, and on their name otherwise. - The hash function ignores space, and stops at the beginning of the - argument list if any. - - The table is laid out in NSYMS/5 buckets and symbols are chained via - their hash_next field. */ - -#if 0 - /* NOTE: carlton/2002-09-24: The rest of the members have been - obsoleted by DICT. */ - - /* If this is really a hashtable of the symbols, this flag is 1. */ - - unsigned char hashtable; - - /* Number of local symbols. */ - - int nsyms; - - /* The symbols. If some of them are arguments, then they must be - in the order in which we would like to print them. */ - - struct symbol *sym[1]; -#endif /* 0 */ }; #define BLOCK_START(bl) (bl)->startaddr @@ -449,35 +430,9 @@ struct block #define BLOCK_FUNCTION(bl) (bl)->function #define BLOCK_SUPERBLOCK(bl) (bl)->superblock #define BLOCK_DICT(bl) (bl)->dict +#define BLOCK_USING(bl) (bl)->language_specific.cplus_specific.using #define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag -#if 0 - -/* NOTE: carlton/2002-09-24: These have been obsoleted by dictionary - stuff. */ -#define BLOCK_HASHTABLE(bl) (bl)->hashtable - -/* For blocks without a hashtable (BLOCK_HASHTABLE (bl) == 0) only. */ -#define BLOCK_NSYMS(bl) (bl)->nsyms -#define BLOCK_SYM(bl, n) (bl)->sym[n] - -/* For blocks with a hashtable, but these are valid for non-hashed blocks as - well - each symbol will appear to be one bucket by itself. */ -#define BLOCK_BUCKETS(bl) (bl)->nsyms -#define BLOCK_BUCKET(bl, n) (bl)->sym[n] - -/* Macro used to set the size of a hashtable for N symbols. */ -#define BLOCK_HASHTABLE_SIZE(n) ((n)/5 + 1) - -/* Macro to loop through all symbols in a block BL, in no particular order. - i counts which bucket we are in, and sym points to the current symbol. */ - -#define ALL_BLOCK_SYMBOLS(bl, i, sym) \ - for ((i) = 0; (i) < BLOCK_BUCKETS ((bl)); (i)++) \ - for ((sym) = BLOCK_BUCKET ((bl), (i)); (sym); \ - (sym) = (sym)->hash_next) -#endif /* 0 */ - /* Represent one symbol name; a variable, constant, function or typedef. */ -- 2.47.2