@@ -445,38 +445,11 @@ ImageEntry* LoadSymbolsForModuleAndCache( const char* imagePath, uint32_t imageN
445445 return CacheModuleInfo ( imagePath, imageNameLength, baseOfDll, dllSize );
446446}
447447
448- void InitCallstack ()
448+ static void CacheProcessDrivers ()
449449{
450- #ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
451- s_shouldResolveSymbolsOffline = ShouldResolveSymbolsOffline ();
452- #endif // #ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
453- if ( s_shouldResolveSymbolsOffline )
454- {
455- TracyDebug (" TRACY: enabling offline symbol resolving!\n " );
456- }
457-
458- CreateImageCaches ();
459-
460- DbgHelpInit ();
461-
462- #ifdef TRACY_DBGHELP_LOCK
463- DBGHELP_LOCK;
464- #endif
465-
466- // use TRACY_NO_DBGHELP_INIT_LOAD=1 to disable preloading of driver
467- // and process module symbol loading at startup time - they will be loaded on demand later
468- // Sometimes this process can take a very long time and prevent resolving callstack frames
469- // symbols during that time.
470- const char * noInitLoadEnv = GetEnvVar ( " TRACY_NO_DBGHELP_INIT_LOAD" );
471- const bool initTimeModuleLoad = !( noInitLoadEnv && noInitLoadEnv[0 ] == ' 1' );
472- if ( !initTimeModuleLoad )
473- {
474- TracyDebug (" TRACY: skipping init time dbghelper module load\n " );
475- }
476-
477450 DWORD needed;
478451 LPVOID dev[4096 ];
479- if ( initTimeModuleLoad && EnumDeviceDrivers ( dev, sizeof (dev), &needed ) != 0 )
452+ if ( EnumDeviceDrivers ( dev, sizeof (dev), &needed ) != 0 )
480453 {
481454 char windir[MAX_PATH];
482455 if ( !GetWindowsDirectoryA ( windir, sizeof ( windir ) ) ) memcpy ( windir, " c:\\ windows" , 11 );
@@ -523,10 +496,14 @@ void InitCallstack()
523496 }
524497 s_krnlCache->Sort ();
525498 }
499+ }
526500
501+ static void CacheProcessModules ()
502+ {
503+ DWORD needed;
527504 HANDLE proc = GetCurrentProcess ();
528505 HMODULE mod[1024 ];
529- if ( initTimeModuleLoad && EnumProcessModules ( proc, mod, sizeof ( mod ), &needed ) != 0 )
506+ if ( EnumProcessModules ( proc, mod, sizeof ( mod ), &needed ) != 0 )
530507 {
531508 const auto sz = needed / sizeof ( HMODULE );
532509 for ( size_t i=0 ; i<sz; i++ )
@@ -545,6 +522,41 @@ void InitCallstack()
545522 }
546523 }
547524 }
525+ }
526+
527+ void InitCallstack ()
528+ {
529+ #ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
530+ s_shouldResolveSymbolsOffline = ShouldResolveSymbolsOffline ();
531+ #endif // #ifndef TRACY_SYMBOL_OFFLINE_RESOLVE
532+ if ( s_shouldResolveSymbolsOffline )
533+ {
534+ TracyDebug (" TRACY: enabling offline symbol resolving!\n " );
535+ }
536+
537+ CreateImageCaches ();
538+
539+ DbgHelpInit ();
540+
541+ #ifdef TRACY_DBGHELP_LOCK
542+ DBGHELP_LOCK;
543+ #endif
544+
545+ // use TRACY_NO_DBGHELP_INIT_LOAD=1 to disable preloading of driver
546+ // and process module symbol loading at startup time - they will be loaded on demand later
547+ // Sometimes this process can take a very long time and prevent resolving callstack frames
548+ // symbols during that time.
549+ const char * noInitLoadEnv = GetEnvVar ( " TRACY_NO_DBGHELP_INIT_LOAD" );
550+ const bool initTimeModuleLoad = !( noInitLoadEnv && noInitLoadEnv[0 ] == ' 1' );
551+ if ( !initTimeModuleLoad )
552+ {
553+ TracyDebug (" TRACY: skipping init time dbghelper module load\n " );
554+ }
555+ else
556+ {
557+ CacheProcessDrivers ();
558+ CacheProcessModules ();
559+ }
548560
549561#ifdef TRACY_DBGHELP_LOCK
550562 DBGHELP_UNLOCK;
0 commit comments