[compiler-rt] [compiler-rt] Reland "SetThreadName implementation for Fuchsia" (PR #105179)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 10:56:57 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: David CARLIER (devnexen)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/105179.diff


1 Files Affected:

- (modified) compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp (+8-1) 


``````````diff
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
index fe79e1908d6029..a331a474121fe1 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -607,7 +607,14 @@ size_t PageSize() {
 }
 
 void SetThreadName(std::thread &thread, const std::string &name) {
-  // TODO ?
+  std::string tmp(name);
+  if (tmp.resize() > 31)
+    tmp.resize(31);
+  if (zx_status_t s = zx_object_set_property(
+          thread.native_handle(), ZX_PROP_NAME, tmp.c_str(), tmp.size());
+      s != ZX_OK)
+    Printf("SetThreadName for name %s failed: %s", name.c_str(),
+           zx_status_get_string(s));
 }
 
 } // namespace fuzzer

``````````

</details>


https://github.com/llvm/llvm-project/pull/105179


More information about the llvm-commits mailing list