mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
* 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.
This commit is contained in:
parent
8a34ac3f58
commit
2e618c13af
@ -1,3 +1,18 @@
|
||||
2008-06-05 Aleksandar Ristovski <aristovski@qnx.com>
|
||||
|
||||
* 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.
|
||||
|
||||
2008-06-05 Aleksandar Ristovski <aristovski@qnx.com>
|
||||
|
||||
* breakpoint.c (print_exception_catchpoint): Put 'exception' back to
|
||||
|
44
gdb/bcache.c
44
gdb/bcache.c
@ -196,12 +196,41 @@ expand_hash_table (struct bcache *bcache)
|
||||
either case, return a pointer to BCACHE's copy of that string. */
|
||||
static void *
|
||||
bcache_data (const void *addr, int length, struct bcache *bcache)
|
||||
{
|
||||
return deprecated_bcache_added (addr, length, bcache, NULL);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
deprecated_bcache (const void *addr, int length, struct bcache *bcache)
|
||||
{
|
||||
return bcache_data (addr, length, bcache);
|
||||
}
|
||||
|
||||
const void *
|
||||
bcache (const void *addr, int length, struct bcache *bcache)
|
||||
{
|
||||
return bcache_data (addr, length, bcache);
|
||||
}
|
||||
|
||||
/* Find a copy of the LENGTH bytes at ADDR in BCACHE. If BCACHE has
|
||||
never seen those bytes before, add a copy of them to BCACHE. In
|
||||
either case, return a pointer to BCACHE's copy of that string. If
|
||||
optional ADDED is not NULL, return 1 in case of new entry or 0 if
|
||||
returning an old entry. */
|
||||
|
||||
void *
|
||||
deprecated_bcache_added (const void *addr, int length, struct bcache *bcache,
|
||||
int *added)
|
||||
{
|
||||
unsigned long full_hash;
|
||||
unsigned short half_hash;
|
||||
int hash_index;
|
||||
struct bstring *s;
|
||||
|
||||
if (added)
|
||||
*added = 0;
|
||||
|
||||
/* If our average chain length is too high, expand the hash table. */
|
||||
if (bcache->unique_count >= bcache->num_buckets * CHAIN_LENGTH_THRESHOLD)
|
||||
expand_hash_table (bcache);
|
||||
@ -242,21 +271,12 @@ bcache_data (const void *addr, int length, struct bcache *bcache)
|
||||
bcache->unique_size += length;
|
||||
bcache->structure_size += BSTRING_SIZE (length);
|
||||
|
||||
if (added)
|
||||
*added = 1;
|
||||
|
||||
return &new->d.data;
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
deprecated_bcache (const void *addr, int length, struct bcache *bcache)
|
||||
{
|
||||
return bcache_data (addr, length, bcache);
|
||||
}
|
||||
|
||||
const void *
|
||||
bcache (const void *addr, int length, struct bcache *bcache)
|
||||
{
|
||||
return bcache_data (addr, length, bcache);
|
||||
}
|
||||
|
||||
/* Allocating and freeing bcaches. */
|
||||
|
||||
|
@ -150,6 +150,8 @@ extern void *deprecated_bcache (const void *addr, int length,
|
||||
extern const void *bcache (const void *addr, int length,
|
||||
struct bcache *bcache);
|
||||
|
||||
extern void *deprecated_bcache_added (const void *addr, int length,
|
||||
struct bcache *bcache, int *added);
|
||||
/* Free all the storage used by BCACHE. */
|
||||
extern void bcache_xfree (struct bcache *bcache);
|
||||
|
||||
|
106
gdb/symfile.c
106
gdb/symfile.c
@ -3082,6 +3082,68 @@ start_psymtab_common (struct objfile *objfile,
|
||||
return (psymtab);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
SYMBOL_VALUE (&psymbol) = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
|
||||
}
|
||||
SYMBOL_SECTION (&psymbol) = 0;
|
||||
SYMBOL_LANGUAGE (&psymbol) = language;
|
||||
PSYMBOL_DOMAIN (&psymbol) = domain;
|
||||
PSYMBOL_CLASS (&psymbol) = class;
|
||||
|
||||
SYMBOL_SET_NAMES (&psymbol, buf, namelength, objfile);
|
||||
|
||||
/* Stash the partial symbol away in the cache */
|
||||
return deprecated_bcache_added (&psymbol, sizeof (struct partial_symbol),
|
||||
objfile->psymbol_cache, added);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
*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. */
|
||||
@ -3100,48 +3162,26 @@ start_psymtab_common (struct objfile *objfile,
|
||||
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 */
|
||||
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;
|
||||
char *buf = alloca (namelength + 1);
|
||||
/* 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';
|
||||
/* val and coreaddr are mutually exclusive, one of them *will* be zero */
|
||||
if (val != 0)
|
||||
{
|
||||
SYMBOL_VALUE (&psymbol) = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
|
||||
}
|
||||
SYMBOL_SECTION (&psymbol) = 0;
|
||||
SYMBOL_LANGUAGE (&psymbol) = language;
|
||||
PSYMBOL_DOMAIN (&psymbol) = domain;
|
||||
PSYMBOL_CLASS (&psymbol) = class;
|
||||
|
||||
SYMBOL_SET_NAMES (&psymbol, buf, namelength, objfile);
|
||||
int added;
|
||||
|
||||
/* Stash the partial symbol away in the cache */
|
||||
psym = deprecated_bcache (&psymbol, sizeof (struct partial_symbol),
|
||||
objfile->psymbol_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. */
|
||||
if (list->next >= list->list + list->size)
|
||||
{
|
||||
extend_psymbol_list (list, objfile);
|
||||
}
|
||||
*list->next++ = psym;
|
||||
OBJSTAT (objfile, n_psyms++);
|
||||
|
||||
append_psymbol_to_list (list, psym, objfile);
|
||||
return psym;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user