[Lldb-commits] [lldb] [lldb-dap] Treat empty thread names as unset (PR #141529)
via lldb-commits
lldb-commits at lists.llvm.org
Mon May 26 13:45:56 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: nerix (Nerixyz)
<details>
<summary>Changes</summary>
When a target thread returned an empty but not `nullptr` string as its name, the thread would show up with an empty name in lldb-dap.
I don't know how this works on macOS and Linux, but on Windows, [`TargetThreadWindows::GetName`](https://github.com/llvm/llvm-project/blob/deedc8a181b9598d188b2175357bce990a271d5d/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp#L178-L204) returns a non-null pointer to an empty string, because on MSVC's STL, `std::string{}.c_str()` returns a pointer to inside the object (the SSO storage).
This changes the check in `CreateThread`, when no custom thread formatter is set, to check for the length of the thread and queue name instead of it being `nullptr`.
---
Full diff: https://github.com/llvm/llvm-project/pull/141529.diff
1 Files Affected:
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+5-5)
``````````diff
diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp
index c9c6f4554c325..f0b3dfb595717 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -764,12 +764,12 @@ llvm::json::Value CreateThread(lldb::SBThread &thread, lldb::SBFormat &format) {
if (format && thread.GetDescriptionWithFormat(format, stream).Success()) {
thread_str = stream.GetData();
} else {
- const char *thread_name = thread.GetName();
- const char *queue_name = thread.GetQueueName();
+ llvm::StringRef thread_name(thread.GetName());
+ llvm::StringRef queue_name(thread.GetQueueName());
- if (thread_name) {
- thread_str = std::string(thread_name);
- } else if (queue_name) {
+ if (!thread_name.empty()) {
+ thread_str = thread_name.str();
+ } else if (!queue_name.empty()) {
auto kind = thread.GetQueue().GetKind();
std::string queue_kind_label = "";
if (kind == lldb::eQueueKindSerial) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/141529
More information about the lldb-commits
mailing list