8311609: [windows] Native stack printing lacks source information for dynamically loaded dlls
Reviewed-by: stuefe, iklam
This commit is contained in:
parent
e51472e9a8
commit
38f74125d1
@ -576,6 +576,11 @@ bool SymbolEngine::recalc_search_path(bool* p_search_path_was_updated) {
|
||||
|
||||
}
|
||||
|
||||
bool SymbolEngine::refreshModuleList() {
|
||||
SymbolEngineEntry entry_guard;
|
||||
return WindowsDbgHelp::symRefreshModuleList(::GetCurrentProcess());
|
||||
}
|
||||
|
||||
bool SymbolEngine::get_source_info(const void* addr, char* buf, size_t buflen,
|
||||
int* line_no)
|
||||
{
|
||||
|
@ -49,6 +49,11 @@ namespace SymbolEngine {
|
||||
// Returns true for success, false for error.
|
||||
bool recalc_search_path(bool* p_search_path_was_updated = nullptr);
|
||||
|
||||
// Refresh the list of loaded modules e.g. pick up any newly loaded dll's
|
||||
// since VM initialization.
|
||||
// Returns true for success, false for error.
|
||||
bool refreshModuleList();
|
||||
|
||||
// Print one liner describing state (if library loaded, which functions are
|
||||
// missing - if any, and the dbhelp API version)
|
||||
void print_state_on(outputStream* st);
|
||||
|
@ -35,6 +35,7 @@ typedef BOOL (WINAPI *pfn_SymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAG
|
||||
typedef DWORD (WINAPI *pfn_UnDecorateSymbolName)(const char*, char*, DWORD, DWORD);
|
||||
typedef BOOL (WINAPI *pfn_SymSetSearchPath)(HANDLE, PCTSTR);
|
||||
typedef BOOL (WINAPI *pfn_SymGetSearchPath)(HANDLE, PTSTR, int);
|
||||
typedef BOOL (WINAPI *pfn_SymRefreshModuleList)(HANDLE);
|
||||
typedef BOOL (WINAPI *pfn_StackWalk64)(DWORD MachineType,
|
||||
HANDLE hProcess,
|
||||
HANDLE hThread,
|
||||
@ -68,7 +69,8 @@ typedef LPAPI_VERSION (WINAPI *pfn_ImagehlpApiVersion)(void);
|
||||
DO(SymFunctionTableAccess64) \
|
||||
DO(SymGetModuleBase64) \
|
||||
DO(MiniDumpWriteDump) \
|
||||
DO(SymGetLineFromAddr64)
|
||||
DO(SymGetLineFromAddr64) \
|
||||
DO(SymRefreshModuleList)
|
||||
|
||||
|
||||
#define DECLARE_FUNCTION_POINTER(functionname) \
|
||||
@ -205,6 +207,14 @@ BOOL WindowsDbgHelp::symGetSearchPath(HANDLE hProcess, PTSTR SearchPath, int Sea
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WindowsDbgHelp::symRefreshModuleList(HANDLE hProcess) {
|
||||
WindowsDbgHelpEntry entry_guard;
|
||||
if (g_pfn_SymRefreshModuleList != nullptr) {
|
||||
return g_pfn_SymRefreshModuleList(hProcess);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WindowsDbgHelp::stackWalk64(DWORD MachineType,
|
||||
HANDLE hProcess,
|
||||
HANDLE hThread,
|
||||
@ -301,4 +311,3 @@ void WindowsDbgHelp::print_state_on(outputStream* st) {
|
||||
}
|
||||
st->cr();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -61,6 +61,7 @@ namespace WindowsDbgHelp {
|
||||
PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
BOOL symGetLineFromAddr64 (HANDLE hProcess, DWORD64 dwAddr,
|
||||
PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line);
|
||||
BOOL symRefreshModuleList(HANDLE hProcess);
|
||||
|
||||
// Print one liner describing state (if library loaded, which functions are
|
||||
// missing - if any, and the dbhelp API version)
|
||||
|
@ -244,6 +244,9 @@ bool os::win32::platform_print_native_stack(outputStream* st, const void* contex
|
||||
stk.AddrPC.Offset = ctx.Rip;
|
||||
stk.AddrPC.Mode = AddrModeFlat;
|
||||
|
||||
// Ensure we consider dynamically loaded dll's
|
||||
SymbolEngine::refreshModuleList();
|
||||
|
||||
int count = 0;
|
||||
address lastpc_internal = 0;
|
||||
while (count++ < StackPrintLimit) {
|
||||
@ -265,6 +268,8 @@ bool os::win32::platform_print_native_stack(outputStream* st, const void* contex
|
||||
int line_no;
|
||||
if (SymbolEngine::get_source_info(pc, buf, sizeof(buf), &line_no)) {
|
||||
st->print(" (%s:%d)", buf, line_no);
|
||||
} else {
|
||||
st->print(" (no source info available)");
|
||||
}
|
||||
st->cr();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user