diff options
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r-- | gdb/buildsym.c | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 5078935..b1962df 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -28,7 +28,7 @@ #include "defs.h" #include "bfd.h" -#include "obstack.h" +#include "gdb_obstack.h" #include "symtab.h" #include "symfile.h" /* Needed for "struct complaint" */ #include "objfiles.h" @@ -40,6 +40,7 @@ #include "bcache.h" #include "filenames.h" /* For DOSish file names */ #include "macrotab.h" +#include "demangle.h" /* Needed by SYMBOL_INIT_DEMANGLED_NAME. */ /* Ask buildsym.h to define the vars it normally declares `extern'. */ #define EXTERN /**/ @@ -243,17 +244,49 @@ finish_block (struct symbol *symbol, struct pending **listhead, /* EMPTY */ ; } - block = (struct block *) obstack_alloc (&objfile->symbol_obstack, - (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *)))); - /* Copy the symbols into the block. */ - BLOCK_NSYMS (block) = i; - for (next = *listhead; next; next = next->next) + if (symbol) + { + block = (struct block *) + obstack_alloc (&objfile->symbol_obstack, + (sizeof (struct block) + + ((i - 1) * sizeof (struct symbol *)))); + BLOCK_NSYMS (block) = i; + for (next = *listhead; next; next = next->next) + for (j = next->nsyms - 1; j >= 0; j--) + { + BLOCK_SYM (block, --i) = next->symbol[j]; + } + } + else { - for (j = next->nsyms - 1; j >= 0; j--) + int htab_size = BLOCK_HASHTABLE_SIZE (i); + + block = (struct block *) + obstack_alloc (&objfile->symbol_obstack, + (sizeof (struct block) + + ((htab_size - 1) * sizeof (struct symbol *)))); + for (j = 0; j < htab_size; j++) + { + BLOCK_BUCKET (block, j) = 0; + } + BLOCK_BUCKETS (block) = htab_size; + for (next = *listhead; next; next = next->next) { - BLOCK_SYM (block, --i) = next->symbol[j]; + for (j = next->nsyms - 1; j >= 0; j--) + { + struct symbol *sym; + unsigned int hash_index; + const char *name = SYMBOL_DEMANGLED_NAME (next->symbol[j]); + if (name == NULL) + name = SYMBOL_NAME (next->symbol[j]); + hash_index = msymbol_hash_iw (name); + hash_index = hash_index % BLOCK_BUCKETS (block); + sym = BLOCK_BUCKET (block, hash_index); + BLOCK_BUCKET (block, hash_index) = next->symbol[j]; + next->symbol[j]->hash_next = sym; + } } } @@ -271,6 +304,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, struct type *ftype = SYMBOL_TYPE (symbol); SYMBOL_BLOCK_VALUE (symbol) = block; BLOCK_FUNCTION (block) = symbol; + BLOCK_HASHTABLE (block) = 0; if (TYPE_NFIELDS (ftype) <= 0) { @@ -352,6 +386,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, else { BLOCK_FUNCTION (block) = NULL; + BLOCK_HASHTABLE (block) = 1; } /* Now "free" the links of the list, and empty the list. */ @@ -451,11 +486,11 @@ record_pending_block (struct objfile *objfile, struct block *block, } } -/* Note that this is only used in this file and in dstread.c, which - should be fixed to not need direct access to this function. When - that is done, it can be made static again. */ +/* OBSOLETE Note that this is only used in this file and in dstread.c, which */ +/* OBSOLETE should be fixed to not need direct access to this function. When */ +/* OBSOLETE that is done, it can be made static again. */ -struct blockvector * +static struct blockvector * make_blockvector (struct objfile *objfile) { register struct pending_block *next; |