Module: wine Branch: master Commit: 7b83b70b06ce6453cf3dc1d81d2af5264ea66a36 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7b83b70b06ce6453cf3dc1d81d...
Author: Eric Pouech eric.pouech@orange.fr Date: Mon Dec 14 22:05:54 2009 +0100
dbghelp: Rewrite the symt* <=> index wrappers to that they work on 64bit platforms.
---
dlls/dbghelp/dbghelp_private.h | 13 +++---------- dlls/dbghelp/module.c | 2 ++ dlls/dbghelp/symbol.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index bb5b990..a0b40a1 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -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); diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 55eca44..53f56c2 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -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 */ diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 17fd6c7..ede588c 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -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;