[PATCH 6/9] [DbgHelp]: rewrite the symt* <=> index wrappers to that they work on 64bit platforms

Eric Pouech eric.pouech at orange.fr
Mon Dec 14 15:05:54 CST 2009




A+
---

 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..52ad52f 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)
+{
+#if defined(__x86_64__)
+    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)
+{
+#if defined(__x86_64__)
+    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;






More information about the wine-patches mailing list