dbghelp: Added a field to the hash table to store the number of elements in the hash table.
Make use of it to get rid to module_compute_num_syms.
This commit is contained in:
parent
4806320b48
commit
a1a879363d
|
@ -82,6 +82,7 @@ struct hash_table_elt
|
|||
|
||||
struct hash_table
|
||||
{
|
||||
unsigned num_elts;
|
||||
unsigned num_buckets;
|
||||
struct hash_table_elt** buckets;
|
||||
};
|
||||
|
@ -422,7 +423,6 @@ extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_th
|
|||
extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
|
||||
|
||||
/* module.c */
|
||||
extern int module_compute_num_syms(struct module* module);
|
||||
extern struct module*
|
||||
module_find_by_addr(const struct process* pcs, unsigned long addr,
|
||||
enum module_type type);
|
||||
|
|
|
@ -284,7 +284,7 @@ BOOL module_get_debug(struct module_pair* pair)
|
|||
}
|
||||
if (!ret) pair->effective->module.SymType = SymNone;
|
||||
assert(pair->effective->module.SymType != SymDeferred);
|
||||
module_compute_num_syms(pair->effective);
|
||||
pair->effective->module.NumSyms = pair->effective->ht_symbols.num_elts;
|
||||
}
|
||||
return pair->effective->module.SymType != SymNone;
|
||||
}
|
||||
|
@ -372,18 +372,6 @@ enum module_type module_get_type_by_name(const char* name)
|
|||
return DMT_PE;
|
||||
}
|
||||
|
||||
int module_compute_num_syms(struct module* module)
|
||||
{
|
||||
struct hash_table_iter hti;
|
||||
void* ptr;
|
||||
|
||||
module->module.NumSyms = 0;
|
||||
hash_table_iter_init(&module->ht_symbols, &hti, NULL);
|
||||
while ((ptr = hash_table_iter_up(&hti)))
|
||||
module->module.NumSyms++;
|
||||
return module->module.NumSyms;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SymLoadModule (DBGHELP.@)
|
||||
*/
|
||||
|
@ -429,7 +417,7 @@ DWORD WINAPI SymLoadModule(HANDLE hProcess, HANDLE hFile, const char* ImageName,
|
|||
WARN("Couldn't locate %s\n", ImageName);
|
||||
return 0;
|
||||
}
|
||||
module_compute_num_syms(module);
|
||||
module->module.NumSyms = module->ht_symbols.num_elts;
|
||||
done:
|
||||
/* by default pe_load_module fills module.ModuleName from a derivation
|
||||
* of ImageName. Overwrite it, if we have better information
|
||||
|
|
|
@ -327,6 +327,7 @@ unsigned hash_table_hash(const char* name, unsigned num_buckets)
|
|||
|
||||
void hash_table_init(struct pool* pool, struct hash_table* ht, unsigned num_buckets)
|
||||
{
|
||||
ht->num_elts = 0;
|
||||
ht->buckets = pool_alloc(pool, num_buckets * sizeof(struct hash_table_elt*));
|
||||
assert(ht->buckets);
|
||||
ht->num_buckets = num_buckets;
|
||||
|
@ -338,7 +339,7 @@ void hash_table_destroy(struct hash_table* ht)
|
|||
#if defined(USE_STATS)
|
||||
int i;
|
||||
unsigned len;
|
||||
unsigned num = 0, min = 0xffffffff, max = 0, sq = 0;
|
||||
unsigned min = 0xffffffff, max = 0, sq = 0;
|
||||
struct hash_table_elt* elt;
|
||||
double mean, variance;
|
||||
|
||||
|
@ -347,13 +348,12 @@ void hash_table_destroy(struct hash_table* ht)
|
|||
for (len = 0, elt = ht->buckets[i]; elt; elt = elt->next) len++;
|
||||
if (len < min) min = len;
|
||||
if (len > max) max = len;
|
||||
num += len;
|
||||
sq += len * len;
|
||||
}
|
||||
mean = (double)num / ht->num_buckets;
|
||||
mean = (double)ht->num_elts / ht->num_buckets;
|
||||
variance = (double)sq / ht->num_buckets - mean * mean;
|
||||
FIXME("STATS: elts[num:%-4u size:%u mean:%f] buckets[min:%-4u variance:%+f max:%-4u]\n",
|
||||
num, ht->num_buckets, mean, min, variance, max);
|
||||
ht->num_elts, ht->num_buckets, mean, min, variance, max);
|
||||
#if 1
|
||||
for (i = 0; i < ht->num_buckets; i++)
|
||||
{
|
||||
|
@ -382,6 +382,7 @@ void hash_table_add(struct hash_table* ht, struct hash_table_elt* elt)
|
|||
for (p = &ht->buckets[hash]; *p; p = &((*p)->next));
|
||||
*p = elt;
|
||||
elt->next = NULL;
|
||||
ht->num_elts++;
|
||||
}
|
||||
|
||||
void* hash_table_find(const struct hash_table* ht, const char* name)
|
||||
|
|
|
@ -623,7 +623,8 @@ static BOOL resort_symbols(struct module* module)
|
|||
struct symt_ht* sym;
|
||||
struct hash_table_iter hti;
|
||||
|
||||
if (!module_compute_num_syms(module)) return FALSE;
|
||||
if (!(module->module.NumSyms = module->ht_symbols.num_elts))
|
||||
return FALSE;
|
||||
|
||||
if (module->addr_sorttab)
|
||||
module->addr_sorttab = HeapReAlloc(GetProcessHeap(), 0,
|
||||
|
|
Loading…
Reference in New Issue