[compiler-rt][fuzzer] implements SetThreadName for fuchsia. (#99953)
GitOrigin-RevId: 31cc4ccdea92a4fee6a327a07251bb0ed1e6a933
diff --git a/FuzzerUtilFuchsia.cpp b/FuzzerUtilFuchsia.cpp
index fe79e19..eefa0b3 100644
--- a/FuzzerUtilFuchsia.cpp
+++ b/FuzzerUtilFuchsia.cpp
@@ -607,7 +607,13 @@
}
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