MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / InitCallstack

Function InitCallstack

Source/ThirdParty/tracy/client/TracyCallstack.cpp:377–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377void InitCallstack()
378{
379#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
380 s_shouldResolveSymbolsOffline = ShouldResolveSymbolsOffline();
381#endif //#ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
382 if( s_shouldResolveSymbolsOffline )
383 {
384 TracyDebug("TRACY: enabling offline symbol resolving!\n");
385 }
386
387 DbgHelpInit();
388
389#ifdef TRACY_DBGHELP_LOCK
390 DBGHELP_LOCK;
391#endif
392
393 // use TRACY_NO_DBGHELP_INIT_LOAD=1 to disable preloading of driver
394 // and process module symbol loading at startup time - they will be loaded on demand later
395 // Sometimes this process can take a very long time and prevent resolving callstack frames
396 // symbols during that time.
397 const char* noInitLoadEnv = GetEnvVar( "TRACY_NO_DBGHELP_INIT_LOAD" );
398 const bool initTimeModuleLoad = !( noInitLoadEnv && noInitLoadEnv[0] == '1' );
399 if ( !initTimeModuleLoad )
400 {
401 TracyDebug("TRACY: skipping init time dbghelper module load\n");
402 }
403
404 DWORD needed;
405 LPVOID dev[4096];
406 if( initTimeModuleLoad && EnumDeviceDrivers( dev, sizeof(dev), &needed ) != 0 )
407 {
408 char windir[MAX_PATH];
409 if( !GetWindowsDirectoryA( windir, sizeof( windir ) ) ) memcpy( windir, "c:\\windows", 11 );
410 const auto windirlen = strlen( windir );
411
412 const auto sz = needed / sizeof( LPVOID );
413 s_krnlCache = (KernelDriver*)tracy_malloc( sizeof(KernelDriver) * sz );
414 int cnt = 0;
415 for( size_t i=0; i<sz; i++ )
416 {
417 char fn[MAX_PATH];
418 const auto len = GetDeviceDriverBaseNameA( dev[i], fn, sizeof( fn ) );
419 if( len != 0 )
420 {
421 auto buf = (char*)tracy_malloc_fast( len+3 );
422 buf[0] = '<';
423 memcpy( buf+1, fn, len );
424 memcpy( buf+len+1, ">", 2 );
425 s_krnlCache[cnt] = KernelDriver { (uint64_t)dev[i], buf };
426
427 const auto len = GetDeviceDriverFileNameA( dev[i], fn, sizeof( fn ) );
428 if( len != 0 )
429 {
430 char full[MAX_PATH];
431 char* path = fn;
432
433 if( memcmp( fn, "\\SystemRoot\\", 12 ) == 0 )
434 {

Callers 1

SymbolWorkerMethod · 0.85

Calls 14

DbgHelpInitFunction · 0.85
GetEnvVarFunction · 0.85
memcpyFunction · 0.85
tracy_mallocFunction · 0.85
tracy_malloc_fastFunction · 0.85
memcmpFunction · 0.85
sortFunction · 0.85
backtrace_create_stateFunction · 0.85

Tested by

no test coverage detected