mirror of
https://github.com/wolfpld/tracy.git
synced 2024-12-01 17:34:36 +00:00
revert #ifdef of a lot of code by TRACY_SYMBOL_OFFLINE_RESOLVE, it now only force enables the offline symbol resolving codepath.
This commit is contained in:
parent
79618c5a1a
commit
301c9fb720
@ -96,11 +96,9 @@ namespace tracy
|
|||||||
// when "TRACY_SYMBOL_OFFLINE_RESOLVE" is set, instead of fully resolving symbols at runtime,
|
// when "TRACY_SYMBOL_OFFLINE_RESOLVE" is set, instead of fully resolving symbols at runtime,
|
||||||
// simply resolve the offset and image name (which will be enough the resolving to be done offline)
|
// simply resolve the offset and image name (which will be enough the resolving to be done offline)
|
||||||
#ifdef TRACY_SYMBOL_OFFLINE_RESOLVE
|
#ifdef TRACY_SYMBOL_OFFLINE_RESOLVE
|
||||||
static constexpr bool s_doOfflineSymbolResolve = true;
|
constexpr bool s_shouldResolveSymbolsOffline = true;
|
||||||
bool ShouldResolveSymbolsOffline() { return true; }
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
bool s_doOfflineSymbolResolve = false;
|
static bool s_shouldResolveSymbolsOffline = false;
|
||||||
bool ShouldResolveSymbolsOffline()
|
bool ShouldResolveSymbolsOffline()
|
||||||
{
|
{
|
||||||
const char* symbolOfflineResolve = GetEnvVar( "TRACY_SYMBOL_OFFLINE_RESOLVE" );
|
const char* symbolOfflineResolve = GetEnvVar( "TRACY_SYMBOL_OFFLINE_RESOLVE" );
|
||||||
@ -158,10 +156,9 @@ void InitCallstackCritical()
|
|||||||
___tracy_RtlWalkFrameChain = (___tracy_t_RtlWalkFrameChain)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlWalkFrameChain" );
|
___tracy_RtlWalkFrameChain = (___tracy_t_RtlWalkFrameChain)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlWalkFrameChain" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
void DbgHelpInit()
|
void DbgHelpInit()
|
||||||
{
|
{
|
||||||
if( s_doOfflineSymbolResolve ) return;
|
if( s_shouldResolveSymbolsOffline ) return;
|
||||||
|
|
||||||
_SymAddrIncludeInlineTrace = (t_SymAddrIncludeInlineTrace)GetProcAddress(GetModuleHandleA("dbghelp.dll"), "SymAddrIncludeInlineTrace");
|
_SymAddrIncludeInlineTrace = (t_SymAddrIncludeInlineTrace)GetProcAddress(GetModuleHandleA("dbghelp.dll"), "SymAddrIncludeInlineTrace");
|
||||||
_SymQueryInlineTrace = (t_SymQueryInlineTrace)GetProcAddress(GetModuleHandleA("dbghelp.dll"), "SymQueryInlineTrace");
|
_SymQueryInlineTrace = (t_SymQueryInlineTrace)GetProcAddress(GetModuleHandleA("dbghelp.dll"), "SymQueryInlineTrace");
|
||||||
@ -183,29 +180,25 @@ void DbgHelpInit()
|
|||||||
|
|
||||||
DWORD64 DbgHelpLoadSymbolsForModule( const char* imageName, uint64_t baseOfDll, uint32_t bllSize )
|
DWORD64 DbgHelpLoadSymbolsForModule( const char* imageName, uint64_t baseOfDll, uint32_t bllSize )
|
||||||
{
|
{
|
||||||
if( s_doOfflineSymbolResolve ) return 0;
|
if( s_shouldResolveSymbolsOffline ) return 0;
|
||||||
return SymLoadModuleEx( GetCurrentProcess(), nullptr, imageName, nullptr, baseOfDll, bllSize, nullptr, 0 );
|
return SymLoadModuleEx( GetCurrentProcess(), nullptr, imageName, nullptr, baseOfDll, bllSize, nullptr, 0 );
|
||||||
}
|
}
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
|
|
||||||
ModuleCache* LoadSymbolsForModuleAndCache( const char* imageName, uint32_t imageNameLength, uint64_t baseOfDll, uint32_t dllSize )
|
ModuleCache* LoadSymbolsForModuleAndCache( const char* imageName, uint32_t imageNameLength, uint64_t baseOfDll, uint32_t dllSize )
|
||||||
{
|
{
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
DbgHelpLoadSymbolsForModule( imageName, baseOfDll, dllSize );
|
DbgHelpLoadSymbolsForModule( imageName, baseOfDll, dllSize );
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
|
|
||||||
ModuleCache* cachedModule = s_modCache->push_next();
|
ModuleCache* cachedModule = s_modCache->push_next();
|
||||||
cachedModule->start = baseOfDll;
|
cachedModule->start = baseOfDll;
|
||||||
cachedModule->end = baseOfDll + dllSize;
|
cachedModule->end = baseOfDll + dllSize;
|
||||||
|
|
||||||
// when doing offline symbol resolution, we must store the full path of the dll for the resolving to work
|
// when doing offline symbol resolution, we must store the full path of the dll for the resolving to work
|
||||||
if( s_doOfflineSymbolResolve )
|
if( s_shouldResolveSymbolsOffline )
|
||||||
{
|
{
|
||||||
cachedModule->name = (char*)tracy_malloc_fast(imageNameLength + 1);
|
cachedModule->name = (char*)tracy_malloc_fast(imageNameLength + 1);
|
||||||
memcpy(cachedModule->name, imageName, imageNameLength);
|
memcpy(cachedModule->name, imageName, imageNameLength);
|
||||||
cachedModule->name[imageNameLength] = '\0';
|
cachedModule->name[imageNameLength] = '\0';
|
||||||
}
|
}
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto ptr = imageName + imageNameLength;
|
auto ptr = imageName + imageNameLength;
|
||||||
@ -218,7 +211,6 @@ ModuleCache* LoadSymbolsForModuleAndCache( const char* imageName, uint32_t image
|
|||||||
cachedModule->name[namelen + 1] = ']';
|
cachedModule->name[namelen + 1] = ']';
|
||||||
cachedModule->name[namelen + 2] = '\0';
|
cachedModule->name[namelen + 2] = '\0';
|
||||||
}
|
}
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
|
|
||||||
return cachedModule;
|
return cachedModule;
|
||||||
}
|
}
|
||||||
@ -226,8 +218,9 @@ ModuleCache* LoadSymbolsForModuleAndCache( const char* imageName, uint32_t image
|
|||||||
void InitCallstack()
|
void InitCallstack()
|
||||||
{
|
{
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
||||||
s_doOfflineSymbolResolve = ShouldResolveSymbolsOffline();
|
s_shouldResolveSymbolsOffline = ShouldResolveSymbolsOffline();
|
||||||
if( s_doOfflineSymbolResolve )
|
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
||||||
|
if( s_shouldResolveSymbolsOffline )
|
||||||
{
|
{
|
||||||
TracyDebug("TRACY: enabling offline symbol resolving!\n");
|
TracyDebug("TRACY: enabling offline symbol resolving!\n");
|
||||||
}
|
}
|
||||||
@ -237,7 +230,6 @@ void InitCallstack()
|
|||||||
#ifdef TRACY_DBGHELP_LOCK
|
#ifdef TRACY_DBGHELP_LOCK
|
||||||
DBGHELP_LOCK;
|
DBGHELP_LOCK;
|
||||||
#endif
|
#endif
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
|
|
||||||
// use TRACY_NO_DBHELP_INIT_LOAD=1 to disable preloading of driver
|
// use TRACY_NO_DBHELP_INIT_LOAD=1 to disable preloading of driver
|
||||||
// and process module symbol loading at startup time - they will be loaded on demand later
|
// and process module symbol loading at startup time - they will be loaded on demand later
|
||||||
@ -286,9 +278,7 @@ void InitCallstack()
|
|||||||
path = full;
|
path = full;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
DbgHelpLoadSymbolsForModule( path, (DWORD64)dev[i], 0 );
|
DbgHelpLoadSymbolsForModule( path, (DWORD64)dev[i], 0 );
|
||||||
# endif
|
|
||||||
|
|
||||||
const auto psz = strlen( path );
|
const auto psz = strlen( path );
|
||||||
auto pptr = (char*)tracy_malloc_fast( psz+1 );
|
auto pptr = (char*)tracy_malloc_fast( psz+1 );
|
||||||
@ -330,11 +320,9 @@ void InitCallstack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
#ifdef TRACY_DBGHELP_LOCK
|
#ifdef TRACY_DBGHELP_LOCK
|
||||||
DBGHELP_UNLOCK;
|
DBGHELP_UNLOCK;
|
||||||
#endif
|
#endif
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndCallstack()
|
void EndCallstack()
|
||||||
@ -343,9 +331,8 @@ void EndCallstack()
|
|||||||
|
|
||||||
const char* DecodeCallstackPtrFast( uint64_t ptr )
|
const char* DecodeCallstackPtrFast( uint64_t ptr )
|
||||||
{
|
{
|
||||||
if( s_doOfflineSymbolResolve ) return "[unresolved]";
|
if( s_shouldResolveSymbolsOffline ) return "[unresolved]";
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
static char ret[MaxNameSize];
|
static char ret[MaxNameSize];
|
||||||
const auto proc = GetCurrentProcess();
|
const auto proc = GetCurrentProcess();
|
||||||
|
|
||||||
@ -370,7 +357,6 @@ const char* DecodeCallstackPtrFast( uint64_t ptr )
|
|||||||
DBGHELP_UNLOCK;
|
DBGHELP_UNLOCK;
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetKernelModulePath( uint64_t addr )
|
const char* GetKernelModulePath( uint64_t addr )
|
||||||
@ -447,7 +433,7 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
|||||||
{
|
{
|
||||||
CallstackSymbolData sym;
|
CallstackSymbolData sym;
|
||||||
|
|
||||||
if( s_doOfflineSymbolResolve )
|
if( s_shouldResolveSymbolsOffline )
|
||||||
{
|
{
|
||||||
sym.file = "[unknown]";
|
sym.file = "[unknown]";
|
||||||
sym.line = 0;
|
sym.line = 0;
|
||||||
@ -455,7 +441,6 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
|||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
IMAGEHLP_LINE64 line;
|
IMAGEHLP_LINE64 line;
|
||||||
DWORD displacement = 0;
|
DWORD displacement = 0;
|
||||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||||
@ -479,7 +464,6 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
|||||||
DBGHELP_UNLOCK;
|
DBGHELP_UNLOCK;
|
||||||
#endif
|
#endif
|
||||||
return sym;
|
return sym;
|
||||||
#endif //TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||||
@ -488,7 +472,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
|||||||
|
|
||||||
const ModuleNameAndBaseAddress moduleNameAndAddress = GetModuleNameAndPrepareSymbols( ptr );
|
const ModuleNameAndBaseAddress moduleNameAndAddress = GetModuleNameAndPrepareSymbols( ptr );
|
||||||
|
|
||||||
if( s_doOfflineSymbolResolve )
|
if( s_shouldResolveSymbolsOffline )
|
||||||
{
|
{
|
||||||
cb_data[0].symAddr = ptr - moduleNameAndAddress.baseAddr;
|
cb_data[0].symAddr = ptr - moduleNameAndAddress.baseAddr;
|
||||||
cb_data[0].symLen = 0;
|
cb_data[0].symLen = 0;
|
||||||
@ -500,7 +484,6 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
|||||||
return { cb_data, 1, moduleNameAndAddress.name };
|
return { cb_data, 1, moduleNameAndAddress.name };
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
int write;
|
int write;
|
||||||
const auto proc = GetCurrentProcess();
|
const auto proc = GetCurrentProcess();
|
||||||
|
|
||||||
@ -611,16 +594,13 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return { cb_data, uint8_t( cb_num ), moduleNameAndAddress.name };
|
return { cb_data, uint8_t( cb_num ), moduleNameAndAddress.name };
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
|
#elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
|
||||||
|
|
||||||
enum { MaxCbTrace = 64 };
|
enum { MaxCbTrace = 64 };
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
struct backtrace_state* cb_bts = nullptr;
|
struct backtrace_state* cb_bts = nullptr;
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
|
|
||||||
int cb_num;
|
int cb_num;
|
||||||
CallstackEntry cb_data[MaxCbTrace];
|
CallstackEntry cb_data[MaxCbTrace];
|
||||||
@ -798,8 +778,9 @@ void InitCallstackCritical()
|
|||||||
void InitCallstack()
|
void InitCallstack()
|
||||||
{
|
{
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
||||||
s_doOfflineSymbolResolve = ShouldResolveSymbolsOffline();
|
s_shouldResolveSymbolsOffline = ShouldResolveSymbolsOffline();
|
||||||
if( s_doOfflineSymbolResolve )
|
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
||||||
|
if( s_shouldResolveSymbolsOffline )
|
||||||
{
|
{
|
||||||
cb_bts = nullptr; // disable use of libbacktrace calls
|
cb_bts = nullptr; // disable use of libbacktrace calls
|
||||||
TracyDebug("TRACY: enabling offline symbol resolving!\n");
|
TracyDebug("TRACY: enabling offline symbol resolving!\n");
|
||||||
@ -808,7 +789,6 @@ void InitCallstack()
|
|||||||
{
|
{
|
||||||
cb_bts = backtrace_create_state( nullptr, 0, nullptr, nullptr );
|
cb_bts = backtrace_create_state( nullptr, 0, nullptr, nullptr );
|
||||||
}
|
}
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
|
|
||||||
#ifndef TRACY_DEMANGLE
|
#ifndef TRACY_DEMANGLE
|
||||||
___tracy_init_demangle_buffer();
|
___tracy_init_demangle_buffer();
|
||||||
@ -948,14 +928,11 @@ static void SymbolAddressErrorCb( void* data, const char* /*msg*/, int /*errnum*
|
|||||||
CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||||
{
|
{
|
||||||
CallstackSymbolData sym;
|
CallstackSymbolData sym;
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
if( cb_bts )
|
if( cb_bts )
|
||||||
{
|
{
|
||||||
backtrace_pcinfo( cb_bts, ptr, SymbolAddressDataCb, SymbolAddressErrorCb, &sym );
|
backtrace_pcinfo( cb_bts, ptr, SymbolAddressDataCb, SymbolAddressErrorCb, &sym );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
{
|
{
|
||||||
SymbolAddressErrorCb(&sym, nullptr, 0);
|
SymbolAddressErrorCb(&sym, nullptr, 0);
|
||||||
}
|
}
|
||||||
@ -963,7 +940,6 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
|||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, const char* fn, int lineno, const char* function )
|
static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, const char* fn, int lineno, const char* function )
|
||||||
{
|
{
|
||||||
cb_data[cb_num].symLen = 0;
|
cb_data[cb_num].symLen = 0;
|
||||||
@ -1062,7 +1038,6 @@ void SymInfoError( void* /*data*/, const char* /*msg*/, int /*errnum*/ )
|
|||||||
cb_data[cb_num-1].symLen = 0;
|
cb_data[cb_num-1].symLen = 0;
|
||||||
cb_data[cb_num-1].symAddr = 0;
|
cb_data[cb_num-1].symAddr = 0;
|
||||||
}
|
}
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
|
|
||||||
void getSymbolForOfflineResolve(void* address, Dl_info& dlinfo, CallstackEntry& cbEntry)
|
void getSymbolForOfflineResolve(void* address, Dl_info& dlinfo, CallstackEntry& cbEntry)
|
||||||
{
|
{
|
||||||
@ -1087,8 +1062,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
|||||||
symloc = dlinfo.dli_fname;
|
symloc = dlinfo.dli_fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
if(cb_bts && !s_shouldResolveSymbolsOffline)
|
||||||
if(cb_bts && !s_doOfflineSymbolResolve)
|
|
||||||
{
|
{
|
||||||
cb_num = 0;
|
cb_num = 0;
|
||||||
backtrace_pcinfo( cb_bts, ptr, CallstackDataCb, CallstackErrorCb, nullptr );
|
backtrace_pcinfo( cb_bts, ptr, CallstackDataCb, CallstackErrorCb, nullptr );
|
||||||
@ -1097,7 +1071,6 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
|||||||
backtrace_syminfo( cb_bts, ptr, SymInfoCallback, SymInfoError, nullptr );
|
backtrace_syminfo( cb_bts, ptr, SymInfoCallback, SymInfoError, nullptr );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
|
|
||||||
{
|
{
|
||||||
cb_num = 1;
|
cb_num = 1;
|
||||||
getSymbolForOfflineResolve( (void*)ptr, dlinfo, cb_data[0] );
|
getSymbolForOfflineResolve( (void*)ptr, dlinfo, cb_data[0] );
|
||||||
|
Loading…
Reference in New Issue
Block a user