[PATCH 6/7] dbghelp: implement SymFromInlineContext when frame is inlined

Eric Pouech eric.pouech at gmail.com
Thu Oct 28 01:58:31 CDT 2021


Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 dlls/dbghelp/dbghelp_private.h |    3 +++
 dlls/dbghelp/symbol.c          |   30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 074685b7173..843c05c27a6 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -927,6 +927,9 @@ static inline struct symt_function*
         inlined = (struct symt_inlinesite*)symt_get_upper_inlined(inlined);
     return &inlined->func;
 }
+extern struct symt_inlinesite*
+                    symt_find_inlined_site(struct module* module,
+                                           DWORD64 addr, DWORD inline_ctx) DECLSPEC_HIDDEN;
 extern DWORD        symt_get_inlinesite_depth(HANDLE hProcess, DWORD64 addr) DECLSPEC_HIDDEN;
 
 /* Inline context encoding (different from what native does):
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c
index 5dd989b5489..503432e461f 100644
--- a/dlls/dbghelp/symbol.c
+++ b/dlls/dbghelp/symbol.c
@@ -1250,6 +1250,24 @@ struct symt* symt_get_upper_inlined(struct symt_inlinesite* inlined)
     return symt;
 }
 
+/* lookup in module for an inline site (from addr and inline_ctx) */
+struct symt_inlinesite* symt_find_inlined_site(struct module* module, DWORD64 addr, DWORD inline_ctx)
+{
+    struct symt_ht* symt = symt_find_nearest(module, addr);
+
+    if (symt_check_tag(&symt->symt, SymTagFunction))
+    {
+        struct symt_function* func = (struct symt_function*)symt;
+        struct symt_inlinesite* curr = symt_find_lowest_inlined(func, addr);
+        DWORD depth = IFC_DEPTH(inline_ctx);
+
+        if (curr)
+            for ( ; &curr->func != func; curr = (struct symt_inlinesite*)symt_get_upper_inlined(curr))
+                if (depth-- == 0) return curr;
+    }
+    return NULL;
+}
+
 DWORD symt_get_inlinesite_depth(HANDLE hProcess, DWORD64 addr)
 {
     struct module_pair pair;
@@ -2626,6 +2644,9 @@ PWSTR WINAPI SymSetHomeDirectoryW(HANDLE hProcess, PCWSTR dir)
  */
 BOOL WINAPI SymFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx, PDWORD64 disp, PSYMBOL_INFO si)
 {
+    struct module_pair pair;
+    struct symt_inlinesite* inlined;
+
     TRACE("(%p, %#I64x, 0x%x, %p, %p)\n", hProcess, addr, inline_ctx, disp, si);
 
     switch (IFC_MODE(inline_ctx))
@@ -2634,6 +2655,15 @@ BOOL WINAPI SymFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx
     case IFC_MODE_REGULAR:
         return SymFromAddr(hProcess, addr, disp, si);
     case IFC_MODE_INLINE:
+        if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
+        inlined = symt_find_inlined_site(pair.effective, addr, inline_ctx);
+        if (inlined)
+        {
+            symt_fill_sym_info(&pair, NULL, &inlined->func.symt, si);
+            *disp = addr - inlined->func.address;
+            return TRUE;
+        }
+        /* fall through */
     default:
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;




More information about the wine-devel mailing list