[Lldb-commits] [lldb] [lldb-dap] Migrating 'threads' request to structured types. (PR #142510)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 4 09:53:02 PDT 2025
================
@@ -110,4 +116,48 @@ std::string GetLoadAddressString(const lldb::addr_t addr) {
return "0x" + llvm::utohexstr(addr, false, 16);
}
+protocol::Thread CreateThread(lldb::SBThread &thread, lldb::SBFormat &format) {
+ std::string name;
+ lldb::SBStream stream;
+ if (format && thread.GetDescriptionWithFormat(format, stream).Success()) {
+ name = stream.GetData();
+ } else {
+ llvm::StringRef thread_name(thread.GetName());
+ llvm::StringRef queue_name(thread.GetQueueName());
+
+ if (!thread_name.empty()) {
+ name = thread_name.str();
+ } else if (!queue_name.empty()) {
+ auto kind = thread.GetQueue().GetKind();
+ std::string queue_kind_label = "";
+ if (kind == lldb::eQueueKindSerial) {
+ queue_kind_label = " (serial)";
+ } else if (kind == lldb::eQueueKindConcurrent) {
+ queue_kind_label = " (concurrent)";
+ }
+
+ name = llvm::formatv("Thread {0} Queue: {1}{2}", thread.GetIndexID(),
+ queue_name, queue_kind_label)
+ .str();
+ } else {
+ name = llvm::formatv("Thread {0}", thread.GetIndexID()).str();
+ }
+ }
+ return protocol::Thread{thread.GetThreadID(), name};
+}
+
+std::vector<protocol::Thread> GetThreads(lldb::SBProcess process,
+ lldb::SBFormat &format) {
+ lldb::SBMutex lock = process.GetTarget().GetAPIMutex();
+ std::lock_guard<lldb::SBMutex> guard(lock);
+
+ std::vector<protocol::Thread> threads;
----------------
ashgti wrote:
Done.
https://github.com/llvm/llvm-project/pull/142510
More information about the lldb-commits
mailing list