-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] fix thread names in debugger / crash dumps #23204
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth backport fix commit only to Nexus
DWORD dwType; // must be 0x1000 | ||
LPCSTR szName; // pointer to name (in same addr space) | ||
DWORD dwThreadID; // thread ID (-1 caller thread) | ||
DWORD dwFlags; // reserved for future use, most be zero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"must be zero"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes done
|
Yes a new PR against the Nexus with only commit: (cherry pick same commit) And if you want also can do the same with: #23017 |
@garbear OK with merge? |
@garbear OK with you to merge? |
Description
Fixed up / updated the way thread names are set so they can be seen in the debugger.
The legacy method used by Kodi so far needed a thread id instead of a thread handle (all Windows platforms)
Added the modern method SetThreadDescription available with Windows 10 1607 and above. The new method adds a few niceties, see https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2022
Both method can coexist, but might as well use only the new one when available, with fallback to the legacy method.
The new method requires dynamic loading as the function does not exist in older versions of Windows
To avoid impacting performance, LoadLibrary/GetProcAddress is done once and a cached pointer is used for every new thread. Could be simplified if thread creation time is a non-issue.
No support added for UWP (covered by legacy method). I'm not familiar with Win RT and didn't find an equivalent that didn't require bundling KernelBase.dll with the app, most likely not a good idea.
Had to define new Windows builds in order to detect Windows 10 1607 properly
Motivation and context
Generic thread names in the debugger make debugging more difficult.
How has this been tested?
Windows 10 22H2 x64 and UWP x64. With old method and new method enabled selectively by special code not included in PR.
What is the effect on users?
none
Screenshots (if appropriate):
Before, generic names assigned by Visual Studio:
After, Kodi specified names:
Types of change
Checklist: