wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
8.67k stars 598 forks source link

Thread IDs instead of names when profiling context switches on Windows #703

Open niello opened 6 months ago

niello commented 6 months ago

Version 0.10.0 Windows 11 MSVC 2022 17.7.6

  1. Create std::thread
  2. Set its name with ::SetThreadDescription(::GetCurrentThread(), SomeName.c_str());
  3. Run regularly, without context switching profiling
  4. Connect tracy
  5. Thread names are present as they were set in p.2
  6. Run Visual Studio under administrator to obtain required privileges on debugged app
  7. Run app under Visual Studio debugger
  8. Connect tracy
  9. Threads created in p.1 have numeric IDs instead of names. Main thread and Tracy threads have names

image image

niello commented 6 months ago

Reproduced once, the second launch is OK. Maybe it is important how you close a profiled application. Either you close it with "X" button and wait for a long time or you stop debugging from inside VS.

niello commented 6 months ago

Probably that's because I didn't use tracy::SetThreadName(name). A strange thing that thread name detection consistently works well without context switching profiling despite the manual says: "Tracy will try to capture thread names through operating system data if context switch capture is active".