Module: wine Branch: master Commit: c99bafb7750badb0013581f13bc5bd560d9b332e URL: https://gitlab.winehq.org/wine/wine/-/commit/c99bafb7750badb0013581f13bc5bd5...
Author: Eric Pouech eric.pouech@gmail.com Date: Fri Nov 18 08:59:11 2022 +0100
dbghelp: Implement SymAddrIncludeInlineTrace().
Replacing symt_get_inlinesite_depth() with SymAddrIncludeInlineTrace() as they look very (very) similar.
Signed-off-by: Eric Pouech eric.pouech@gmail.com
---
dlls/dbghelp/dbghelp_private.h | 1 - dlls/dbghelp/stack.c | 4 ++-- dlls/dbghelp/symbol.c | 45 +++++++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 22e9eec8805..177032d0ff4 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -953,7 +953,6 @@ static inline struct symt_function* extern struct symt_function* 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): * bits 31:30: 3 ignore (includes INLINE_FRAME_CONTEXT_IGNORE=0xFFFFFFFF) diff --git a/dlls/dbghelp/stack.c b/dlls/dbghelp/stack.c index 97bd885dcc7..8b573feee77 100644 --- a/dlls/dbghelp/stack.c +++ b/dlls/dbghelp/stack.c @@ -312,7 +312,7 @@ BOOL WINAPI StackWalkEx(DWORD MachineType, HANDLE hProcess, HANDLE hThread,
if (IFC_MODE(frame->InlineFrameContext) == IFC_MODE_INLINE) { - DWORD depth = symt_get_inlinesite_depth(hProcess, addr); + DWORD depth = SymAddrIncludeInlineTrace(hProcess, addr); if (IFC_DEPTH(frame->InlineFrameContext) + 1 < depth) /* move to next inlined function? */ { TRACE("found inline ctx: depth=%lu current=%lu++\n", @@ -330,7 +330,7 @@ BOOL WINAPI StackWalkEx(DWORD MachineType, HANDLE hProcess, HANDLE hThread, if (frame->InlineFrameContext != INLINE_FRAME_CONTEXT_IGNORE) { addr = sw_xlat_addr(&csw, &frame->AddrPC); - frame->InlineFrameContext = symt_get_inlinesite_depth(hProcess, addr) == 0 ? IFC_MODE_REGULAR : IFC_MODE_INLINE; + frame->InlineFrameContext = SymAddrIncludeInlineTrace(hProcess, addr) == 0 ? IFC_MODE_REGULAR : IFC_MODE_INLINE; TRACE("setting IFC mode to %lx\n", frame->InlineFrameContext); } } diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 514991af386..72634443cb7 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1265,27 +1265,6 @@ struct symt_function* symt_find_inlined_site(struct module* module, DWORD64 addr return NULL; }
-DWORD symt_get_inlinesite_depth(HANDLE hProcess, DWORD64 addr) -{ - struct module_pair pair; - DWORD depth = 0; - - if (module_init_pair(&pair, hProcess, addr)) - { - struct symt_ht* symt = symt_find_symbol_at(pair.effective, addr); - if (symt_check_tag(&symt->symt, SymTagFunction)) - { - struct symt_function* inlined = symt_find_lowest_inlined((struct symt_function*)symt, addr); - if (inlined) - { - for ( ; &inlined->symt != &symt->symt; inlined = (struct symt_function*)symt_get_upper_inlined(inlined)) - ++depth; - } - } - } - return depth; -} - /****************************************************************** * sym_enum * @@ -2797,11 +2776,31 @@ BOOL WINAPI SymGetLineFromInlineContextW(HANDLE hProcess, DWORD64 addr, ULONG in /****************************************************************** * SymAddrIncludeInlineTrace (DBGHELP.@) * + * MSDN doesn't state that the maximum depth (of embedded inline sites) at <addr> + * is actually returned. (It just says non zero means that there are some inline site(s)). + * But this is what native actually returns. */ DWORD WINAPI SymAddrIncludeInlineTrace(HANDLE hProcess, DWORD64 addr) { - FIXME("(%p, %I64x): stub\n", hProcess, addr); - return 0; + struct module_pair pair; + DWORD depth = 0; + + TRACE("(%p, %#I64x)\n", hProcess, addr); + + if (module_init_pair(&pair, hProcess, addr)) + { + struct symt_ht* symt = symt_find_symbol_at(pair.effective, addr); + if (symt_check_tag(&symt->symt, SymTagFunction)) + { + struct symt_function* inlined = symt_find_lowest_inlined((struct symt_function*)symt, addr); + if (inlined) + { + for ( ; &inlined->symt != &symt->symt; inlined = (struct symt_function*)symt_get_upper_inlined(inlined)) + ++depth; + } + } + } + return depth; }
/******************************************************************