[PATCH 14/15] dbghelp: added first implementations for SymGetLineFromInlineContext(W)

Eric Pouech eric.pouech at gmail.com
Fri Oct 22 02:16:22 CDT 2021


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

---
 dlls/dbghelp/symbol.c |   91 +++++++++++++++++++++++++++++++++++--------------
 1 file changed, 65 insertions(+), 26 deletions(-)

diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c
index 459f282502a..938dac2dd3c 100644
--- a/dlls/dbghelp/symbol.c
+++ b/dlls/dbghelp/symbol.c
@@ -1845,28 +1845,14 @@ static BOOL internal_line_set_nameW(struct process* pcs, struct internal_line_t*
     return TRUE;
 }
 
-/******************************************************************
- *		get_line_from_addr
- *
- * fills source file information from an address
- */
-static BOOL get_line_from_addr(HANDLE hProcess, DWORD64 addr,
-                               PDWORD pdwDisplacement, struct internal_line_t* intl)
+static BOOL get_line_from_function(struct module_pair* pair, struct symt_function* func, DWORD64 addr,
+                                   PDWORD pdwDisplacement, struct internal_line_t* intl)
 {
     struct line_info*           dli = NULL;
     struct line_info*           found_dli = NULL;
     int                         i;
-    struct module_pair          pair;
-    struct symt_ht*             symt;
-    struct symt_function*       func;
-
-    if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
-    if ((symt = symt_find_nearest(pair.effective, addr)) == NULL) return FALSE;
 
-    if (symt->symt.tag != SymTagFunction) return FALSE;
-    func = (struct symt_function*)symt;
-
-    for (i=vector_length(&func->vlines)-1; i>=0; i--)
+    for (i = vector_length(&func->vlines) - 1; i >= 0; i--)
     {
         dli = vector_at(&func->vlines, i);
         if (!dli->is_source_file)
@@ -1884,12 +1870,12 @@ static BOOL get_line_from_addr(HANDLE hProcess, DWORD64 addr,
             if (dbghelp_opt_native)
             {
                 /* Return native file paths when using winedbg */
-                ret = internal_line_set_nameA(pair.pcs, intl, (char*)source_get(pair.effective, dli->u.source_file), FALSE);
+                ret = internal_line_set_nameA(pair->pcs, intl, (char*)source_get(pair->effective, dli->u.source_file), FALSE);
             }
             else
             {
-                WCHAR *dospath = wine_get_dos_file_name(source_get(pair.effective, dli->u.source_file));
-                ret = internal_line_set_nameW(pair.pcs, intl, dospath, TRUE);
+                WCHAR *dospath = wine_get_dos_file_name(source_get(pair->effective, dli->u.source_file));
+                ret = internal_line_set_nameW(pair->pcs, intl, dospath, TRUE);
                 HeapFree( GetProcessHeap(), 0, dospath );
             }
             if (ret) *pdwDisplacement = addr - found_dli->u.address;
@@ -1899,6 +1885,24 @@ static BOOL get_line_from_addr(HANDLE hProcess, DWORD64 addr,
     return FALSE;
 }
 
+/******************************************************************
+ *		get_line_from_addr
+ *
+ * fills source file information from an address
+ */
+static BOOL get_line_from_addr(HANDLE hProcess, DWORD64 addr,
+                               PDWORD pdwDisplacement, struct internal_line_t* intl)
+{
+    struct module_pair          pair;
+    struct symt_ht*             symt;
+
+    if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
+    if ((symt = symt_find_nearest(pair.effective, addr)) == NULL) return FALSE;
+
+    if (symt->symt.tag != SymTagFunction && symt->symt.tag != SymTagInlineSite) return FALSE;
+    return get_line_from_function(&pair, (struct symt_function*)symt, addr, pdwDisplacement, intl);
+}
+
 /***********************************************************************
  *		SymGetSymNext64 (DBGHELP.@)
  */
@@ -2697,16 +2701,45 @@ BOOL WINAPI SymFromInlineContextW(HANDLE hProcess, DWORD64 addr, ULONG inline_ct
     return ret;
 }
 
+static BOOL get_line_from_inline_context(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx, DWORD64 mod_addr, PDWORD disp,
+                                         struct internal_line_t* intl)
+{
+    struct module_pair pair;
+    struct symt_inlinesite* inlined;
+
+    if (!module_init_pair(&pair, hProcess, mod_addr ? mod_addr : addr)) return FALSE;
+    switch (IFC_MODE(inline_ctx))
+    {
+    case IFC_MODE_INLINE:
+        inlined = symt_find_inlined_site(pair.effective, addr, inline_ctx);
+        if (inlined && get_line_from_function(&pair, &inlined->func, addr, disp, intl))
+            return TRUE;
+        /* fall through: check if we can find line info at top function level */
+    case IFC_MODE_IGNORE:
+    case IFC_MODE_REGULAR:
+        return get_line_from_addr(hProcess, addr, disp, intl);
+    default:
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+}
+
 /******************************************************************
  *		SymGetLineFromInlineContext (DBGHELP.@)
  *
  */
 BOOL WINAPI SymGetLineFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx, DWORD64 mod_addr, PDWORD disp, PIMAGEHLP_LINE64 line)
 {
-    FIXME("(%p, %#I64x, 0x%x, %#I64x, %p, %p): stub!\n",
+    struct internal_line_t intl;
+
+    TRACE("(%p, %#I64x, 0x%x, %#I64x, %p, %p): stub!\n",
           hProcess, addr, inline_ctx, mod_addr, disp, line);
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
+
+    if (line->SizeOfStruct < sizeof(*line)) return FALSE;
+    init_internal_line(&intl, FALSE);
+
+    if (!get_line_from_inline_context(hProcess, addr, inline_ctx, mod_addr, disp, &intl)) return FALSE;
+    return internal_line_copy_toA64(&intl, line);
 }
 
 /******************************************************************
@@ -2715,8 +2748,14 @@ BOOL WINAPI SymGetLineFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inl
  */
 BOOL WINAPI SymGetLineFromInlineContextW(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx, DWORD64 mod_addr, PDWORD disp, PIMAGEHLP_LINEW64 line)
 {
-    FIXME("(%p, %#I64x, 0x%x, %#I64x, %p, %p): stub!\n",
+    struct internal_line_t intl;
+
+    TRACE("(%p, %#I64x, 0x%x, %#I64x, %p, %p): stub!\n",
           hProcess, addr, inline_ctx, mod_addr, disp, line);
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
+
+    if (line->SizeOfStruct < sizeof(*line)) return FALSE;
+    init_internal_line(&intl, TRUE);
+
+    if (!get_line_from_inline_context(hProcess, addr, inline_ctx, mod_addr, disp, &intl)) return FALSE;
+    return internal_line_copy_toW64(&intl, line);
 }




More information about the wine-devel mailing list