dbghelp: Rewrite the symt* <=> index wrappers to that they work on 64bit platforms.

This commit is contained in:
Eric Pouech 2009-12-14 22:05:54 +01:00 committed by Alexandre Julliard
parent 92b9b0940d
commit 7b83b70b06
3 changed files with 36 additions and 10 deletions

View file

@ -335,6 +335,7 @@ struct module
struct pool pool;
/* symbols & symbol tables */
struct vector vsymt;
int sortlist_valid;
unsigned num_sorttab; /* number of symbols with addresses */
unsigned num_symbols;
@ -418,16 +419,6 @@ struct pdb_lookup
} u;
};
static inline DWORD symt_ptr2index(struct module* module, const struct symt* sym)
{
return (DWORD)sym;
}
static inline struct symt* symt_index2ptr(struct module* module, DWORD id)
{
return (struct symt*)id;
}
/* dbghelp.c */
extern struct process* process_find_by_handle(HANDLE hProcess);
extern HANDLE hMsvcrt;
@ -614,6 +605,8 @@ extern struct symt_hierarchy_point*
symt_new_label(struct module* module,
struct symt_compiland* compiland,
const char* name, unsigned long address);
extern struct symt* symt_index2ptr(struct module* module, DWORD id);
extern DWORD symt_ptr2index(struct module* module, const struct symt* sym);
/* type.c */
extern void symt_init_basic(struct module* module);

View file

@ -173,6 +173,8 @@ struct module* module_new(struct process* pcs, const WCHAR* name,
module->addr_sorttab = NULL;
module->num_sorttab = 0;
module->num_symbols = 0;
vector_init(&module->vsymt, sizeof(struct symt*), 128);
/* FIXME: this seems a bit too high (on a per module basis)
* need some statistics about this
*/

View file

@ -69,6 +69,37 @@ int symt_cmp_addr(const void* p1, const void* p2)
return cmp_addr(a1, a2);
}
DWORD symt_ptr2index(struct module* module, const struct symt* sym)
{
#ifdef _WIN64
const struct symt** c;
int len = vector_length(&module->vsymt), i;
/* FIXME: this is inefficient */
for (i = 0; i < len; i++)
{
if (*(struct symt**)vector_at(&module->vsymt, i) == sym)
return i + 1;
}
/* not found */
c = vector_add(&module->vsymt, &module->pool);
if (c) *c = sym;
return len + 1;
#else
return (DWORD)sym;
#endif
}
struct symt* symt_index2ptr(struct module* module, DWORD id)
{
#ifdef _WIN64
if (!id-- || id >= vector_length(&module->vsymt)) return NULL;
return *(struct symt**)vector_at(&module->vsymt, id);
#else
return (struct symt*)id;
#endif
}
static BOOL symt_grow_sorttab(struct module* module, unsigned sz)
{
struct symt_ht** new;