[compiler-rt] [compiler-rt] Reland "SetThreadName implementation for Fuchsia" (PR #105179)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 11:45:13 PDT 2024
https://github.com/devnexen updated https://github.com/llvm/llvm-project/pull/105179
>From 91327e929fbdbe13a1643902f1bc94f0dc69cd7d Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Tue, 20 Aug 2024 18:55:18 +0100
Subject: [PATCH 1/2] [compiler-rt] Reland "SetThreadName implementation for
Fuchsia"
---
compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
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
>From fefdedcd681c4a8c9449cc1b85a262380a6d28ad Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Tue, 20 Aug 2024 19:44:41 +0100
Subject: [PATCH 2/2] simplification from feedback
---
compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
index a331a474121fe1..735d1555d30532 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -607,11 +607,8 @@ size_t PageSize() {
}
void SetThreadName(std::thread &thread, const std::string &name) {
- 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());
+ thread.native_handle(), ZX_PROP_NAME, name.data(), name.size());
s != ZX_OK)
Printf("SetThreadName for name %s failed: %s", name.c_str(),
zx_status_get_string(s));
More information about the llvm-commits
mailing list