[compiler-rt] [compiler-rt][fuzzer] implements SetThreadName for fuchsia. (PR #99953)

David CARLIER via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 23:54:13 PDT 2024


https://github.com/devnexen updated https://github.com/llvm/llvm-project/pull/99953

>From c0956ec22decc7aaef7acfa249af32bd6b22d465 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Mon, 22 Jul 2024 22:19:43 +0100
Subject: [PATCH] [compiler-rt][fuzzer] implements SetThreadName for fuchsia.

---
 compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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



More information about the llvm-commits mailing list