[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)
Saleem Abdulrasool via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 11 16:59:03 PST 2023
================
@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
return Status();
}
+
+const char *TargetThreadWindows::GetName() {
+ Log *log = GetLog(LLDBLog::Thread);
+ HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+ if (hModule) {
+ auto GetThreadDescription =
+ reinterpret_cast<GetThreadDescriptionFunctionPtr>(
+ ::GetProcAddress(hModule, "GetThreadDescription"));
----------------
compnerd wrote:
If there is compatibility that we are concerned about, I think that we should consider falling back to more ... esoteric solutions.
```c++
__try {
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
} __except (EXCEPTION_EXECUTE_HANDLER) {
}
```
Should be far more portable and is what VS also uses. This is documented at https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2015&redirectedfrom=MSDN.
I would be okay with also raising the requirements to a newer version of Windows as 1607 is RS1 which makes it more than 8 years old at this point.
https://github.com/llvm/llvm-project/pull/74731
More information about the lldb-commits
mailing list