dbghelp: Implemented SymFunctionTableAccess.
authorEric Pouech <eric.pouech@orange.fr>
Sat, 20 Mar 2010 08:47:24 +0000 (09:47 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 22 Mar 2010 10:27:36 +0000 (11:27 +0100)
dlls/dbghelp/cpu_i386.c
dlls/dbghelp/cpu_ppc.c
dlls/dbghelp/cpu_x86_64.c
dlls/dbghelp/dbghelp_private.h
dlls/dbghelp/module.c
dlls/dbghelp/symbol.c

index f3de65235392e0e1dfb19db723fbe600f1ee984f..47610e69676c9381619d634246bf08f5b38682d1 100644 (file)
@@ -409,4 +409,5 @@ struct cpu cpu_i386 = {
     4,
     i386_get_addr,
     i386_stack_walk,
+    NULL,
 };
index fca5ec76ccf4cdfc4110c58f2d742c54269db3da..6efa3f85362a2eabbf025ec06273c9427b7e9592 100644 (file)
@@ -59,4 +59,5 @@ struct cpu cpu_ppc = {
     4,
     ppc_get_addr,
     ppc_stack_walk,
+    NULL,
 };
index cd0e32c50810e7ba39284205fb6f48d8e93e0747..a56a80015bfac7cab55baef49901a8904137bead 100644 (file)
@@ -124,9 +124,39 @@ done_err:
     return FALSE;
 }
 
+static void*    x86_64_find_runtime_function(struct module* module, DWORD64 addr)
+{
+#ifdef __x86_64__
+    RUNTIME_FUNCTION*   rtf;
+    ULONG               size;
+    int                 min, max;
+
+    rtf = (RUNTIME_FUNCTION*)pe_map_directory(module, IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size);
+    if (rtf) for (min = 0, max = size / sizeof(*rtf); min <= max; )
+    {
+        int pos = (min + max) / 2;
+        if (addr < module->module.BaseOfImage + rtf[pos].BeginAddress) max = pos - 1;
+        else if (addr >= module->module.BaseOfImage + rtf[pos].EndAddress) min = pos + 1;
+        else
+        {
+            rtf += pos;
+            while (rtf->UnwindData & 1)  /* follow chained entry */
+            {
+                FIXME("RunTime_Function outside IMAGE_DIRECTORY_ENTRY_EXCEPTION unimplemented yet!\n");
+                /* we need to read into the other process */
+                /* rtf = (RUNTIME_FUNCTION*)(module->module.BaseOfImage + (rtf->UnwindData & ~1)); */
+            }
+            return rtf;
+        }
+    }
+#endif
+    return NULL;
+}
+
 struct cpu cpu_x86_64 = {
     IMAGE_FILE_MACHINE_AMD64,
     8,
     x86_64_get_addr,
     x86_64_stack_walk,
+    x86_64_find_runtime_function,
 };
index 42234ee16cce2439c3375d2018c4a2dddfd84c32..54b7272b2115fe2dd8027278d7361085289ab9b5 100644 (file)
@@ -475,6 +475,9 @@ struct cpu
 
     /* stack manipulation */
     BOOL        (*stack_walk)(struct cpu_stack_walk* csw, LPSTACKFRAME64 frame);
+
+    /* module manipulation */
+    void*       (*find_runtime_function)(struct module*, DWORD64 addr);
 };
 
 extern struct cpu*      dbghelp_current_cpu;
index 250c5a5854a3b8b6862d927bc5f36c8182857ad6..eadc67a9ada42484a76fc1a6455827568ffd784b 100644 (file)
@@ -1087,3 +1087,26 @@ BOOL WINAPI SymRefreshModuleList(HANDLE hProcess)
 
     return refresh_module_list(pcs);
 }
+
+/***********************************************************************
+ *             SymFunctionTableAccess (DBGHELP.@)
+ */
+PVOID WINAPI SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase)
+{
+    return SymFunctionTableAccess64(hProcess, AddrBase);
+}
+
+/***********************************************************************
+ *             SymFunctionTableAccess64 (DBGHELP.@)
+ */
+PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase)
+{
+    struct process*     pcs = process_find_by_handle(hProcess);
+    struct module*      module;
+
+    if (!pcs || !dbghelp_current_cpu->find_runtime_function) return NULL;
+    module = module_find_by_addr(pcs, AddrBase, DMT_UNKNOWN);
+    if (!module) return NULL;
+
+    return dbghelp_current_cpu->find_runtime_function(module, AddrBase);
+}
index 650f6a28086062daa5089a4f1a1006297b470baf..fa9459e451bd6e947e146a835e07373d9aae7143 100644 (file)
@@ -1793,24 +1793,6 @@ BOOL WINAPI SymGetLineNext(HANDLE hProcess, PIMAGEHLP_LINE Line)
     return TRUE;
 }
 
-/***********************************************************************
- *             SymFunctionTableAccess (DBGHELP.@)
- */
-PVOID WINAPI SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase)
-{
-    WARN("(%p, 0x%08x): stub\n", hProcess, AddrBase);
-    return NULL;
-}
-
-/***********************************************************************
- *             SymFunctionTableAccess64 (DBGHELP.@)
- */
-PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase)
-{
-    WARN("(%p, %s): stub\n", hProcess, wine_dbgstr_longlong(AddrBase));
-    return NULL;
-}
-
 /***********************************************************************
  *             SymUnDName (DBGHELP.@)
  */