[compiler-rt] e3f935c - [Fuzzer] SetThreadName implementation for Windows
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 26 22:55:15 PDT 2023
Author: David CARLIER
Date: 2023-07-27T06:55:00+01:00
New Revision: e3f935c7f80cfb8bdcbe0479672bc92485eecd85
URL: https://github.com/llvm/llvm-project/commit/e3f935c7f80cfb8bdcbe0479672bc92485eecd85
DIFF: https://github.com/llvm/llvm-project/commit/e3f935c7f80cfb8bdcbe0479672bc92485eecd85.diff
LOG: [Fuzzer] SetThreadName implementation for Windows
Api available since Windows Server 2016/Windows 10 1607.
Reviewers: vitalybuka
Reviewed-By: vitalybuka
Differential Revision: https://reviews.llvm.org/D156317
Added:
Modified:
compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index 71770166805f78..a59a4960e3e1c5 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -24,7 +24,9 @@
#include <windows.h>
// This must be included after windows.h.
+#include <processthreadsapi.h>
#include <psapi.h>
+#include <stringapiset.h>
namespace fuzzer {
@@ -234,8 +236,9 @@ size_t PageSize() {
}
void SetThreadName(std::thread &thread, const std::string &name) {
- // TODO ?
- // to UTF-8 then SetThreadDescription ?
+ wchar_t wname[16];
+ if (MultiByteToWideChar(CP_UTF8, 0, name.c_str(), -1, wname, 16) > 0)
+ (void)SetThreadDescription(thread.native_handle(), wname);
}
} // namespace fuzzer
More information about the llvm-commits
mailing list