diff options
author | Aleksandar Ristovski <aristovski@qnx.com> | 2008-06-05 19:21:55 +0000 |
---|---|---|
committer | Aleksandar Ristovski <aristovski@qnx.com> | 2008-06-05 19:21:55 +0000 |
commit | 2e618c13af17f36d0f0173786d49abea7308dc24 (patch) | |
tree | d25c6e97d0ee183dcba1b54d3f2d0ec0679188dc /gdb/symfile.c | |
parent | 8a34ac3f587db129417fd57104477cd186b666c8 (diff) | |
download | gdb-2e618c13af17f36d0f0173786d49abea7308dc24.zip gdb-2e618c13af17f36d0f0173786d49abea7308dc24.tar.gz gdb-2e618c13af17f36d0f0173786d49abea7308dc24.tar.bz2 |
* bcache.c (bcache_data): Call deprecated_bcache_added function.
(deprecated_bcache_added): New function name. Body of function
bcache_data is used here with the addition of 'added' argument.
* bcache.h (deprecated_bcache_added): New function.
* symfile.c (add_psymbol_to_bcache): New helper function, takes part of
work from add_psymbol_to_list - initialises partial symbol and stashes
it in objfile's cache.
(append_psymbol_to_list): New helper function, takes other part of
work from add_psymbol_to_list - adds partial symbol to the given list.
(add_psymbol_to_list): Call helper functions instead of doing work
here. If adding to global list, do not duplicate partial symbols in the
partial symtab.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r-- | gdb/symfile.c | 106 |
1 files changed, 73 insertions, 33 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c index 99bebc8..d0596e6 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3082,38 +3082,33 @@ start_psymtab_common (struct objfile *objfile, return (psymtab); } -/* Add a symbol with a long value to a psymtab. - Since one arg is a struct, we pass in a ptr and deref it (sigh). - Return the partial symbol that has been added. */ - -/* NOTE: carlton/2003-09-11: The reason why we return the partial - symbol is so that callers can get access to the symbol's demangled - name, which they don't have any cheap way to determine otherwise. - (Currenly, dwarf2read.c is the only file who uses that information, - though it's possible that other readers might in the future.) - Elena wasn't thrilled about that, and I don't blame her, but we - couldn't come up with a better way to get that information. If - it's needed in other situations, we could consider breaking up - SYMBOL_SET_NAMES to provide access to the demangled name lookup - cache. */ - -const struct partial_symbol * -add_psymbol_to_list (char *name, int namelength, domain_enum domain, - enum address_class class, - struct psymbol_allocation_list *list, long val, /* Value as a long */ - CORE_ADDR coreaddr, /* Value as a CORE_ADDR */ - enum language language, struct objfile *objfile) +/* Helper function, initialises partial symbol structure and stashes + it into objfile's bcache. Note that our caching mechanism will + use all fields of struct partial_symbol to determine hash value of the + structure. In other words, having two symbols with the same name but + different domain (or address) is possible and correct. */ + +static struct partial_symbol * +add_psymbol_to_bcache (char *name, int namelength, domain_enum domain, + enum address_class class, + long val, /* Value as a long */ + CORE_ADDR coreaddr, /* Value as a CORE_ADDR */ + enum language language, struct objfile *objfile, + int *added) { - struct partial_symbol *psym; - char *buf = alloca (namelength + 1); + char *buf = name; /* psymbol is static so that there will be no uninitialized gaps in the structure which might contain random data, causing cache misses in bcache. */ static struct partial_symbol psymbol; - - /* Create local copy of the partial symbol */ - memcpy (buf, name, namelength); - buf[namelength] = '\0'; + + if (name[namelength] != '\0') + { + buf = alloca (namelength + 1); + /* Create local copy of the partial symbol */ + memcpy (buf, name, namelength); + buf[namelength] = '\0'; + } /* val and coreaddr are mutually exclusive, one of them *will* be zero */ if (val != 0) { @@ -3131,17 +3126,62 @@ add_psymbol_to_list (char *name, int namelength, domain_enum domain, SYMBOL_SET_NAMES (&psymbol, buf, namelength, objfile); /* Stash the partial symbol away in the cache */ - psym = deprecated_bcache (&psymbol, sizeof (struct partial_symbol), - objfile->psymbol_cache); + return deprecated_bcache_added (&psymbol, sizeof (struct partial_symbol), + objfile->psymbol_cache, added); +} - /* Save pointer to partial symbol in psymtab, growing symtab if needed. */ +/* Helper function, adds partial symbol to the given partial symbol + list. */ + +static void +append_psymbol_to_list (struct psymbol_allocation_list *list, + struct partial_symbol *psym, + struct objfile *objfile) +{ if (list->next >= list->list + list->size) - { - extend_psymbol_list (list, objfile); - } + extend_psymbol_list (list, objfile); *list->next++ = psym; OBJSTAT (objfile, n_psyms++); +} + +/* Add a symbol with a long value to a psymtab. + Since one arg is a struct, we pass in a ptr and deref it (sigh). + Return the partial symbol that has been added. */ + +/* NOTE: carlton/2003-09-11: The reason why we return the partial + symbol is so that callers can get access to the symbol's demangled + name, which they don't have any cheap way to determine otherwise. + (Currenly, dwarf2read.c is the only file who uses that information, + though it's possible that other readers might in the future.) + Elena wasn't thrilled about that, and I don't blame her, but we + couldn't come up with a better way to get that information. If + it's needed in other situations, we could consider breaking up + SYMBOL_SET_NAMES to provide access to the demangled name lookup + cache. */ +const struct partial_symbol * +add_psymbol_to_list (char *name, int namelength, domain_enum domain, + enum address_class class, + struct psymbol_allocation_list *list, + long val, /* Value as a long */ + CORE_ADDR coreaddr, /* Value as a CORE_ADDR */ + enum language language, struct objfile *objfile) +{ + struct partial_symbol *psym; + + int added; + + /* Stash the partial symbol away in the cache */ + psym = add_psymbol_to_bcache (name, namelength, domain, class, + val, coreaddr, language, objfile, &added); + + /* Do not duplicate global partial symbols. */ + if (list == &objfile->global_psymbols + && !added) + return psym; + + /* Save pointer to partial symbol in psymtab, growing symtab if needed. */ + append_psymbol_to_list (list, psym, objfile); return psym; } |