aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-22 19:00:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-12-06 16:30:02 +0000
commit5f7ddb1456d5b926e85710da690bf548ef0c9fc8 (patch)
treef8845b108c5c07836b95c8229c96cd745fc9fb2c /contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp
parent3f82687cdf02983d8f3294df4d97b09cf211141b (diff)
Diffstat (limited to 'contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp
index b93698c7be60..d330da7e684e 100644
--- a/contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp
+++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp
@@ -58,7 +58,6 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command,
if (!llvm::to_integer(command.GetArgumentAtIndex(i), thread_idx)) {
result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
command.GetArgumentAtIndex(i));
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -68,7 +67,6 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command,
if (!thread) {
result.AppendErrorWithFormat("no thread with index: \"%s\"\n",
command.GetArgumentAtIndex(i));
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -129,7 +127,6 @@ bool CommandObjectIterateOverThreads::BucketThread(
Thread *thread = process->GetThreadList().FindThreadByID(tid).get();
if (thread == nullptr) {
result.AppendErrorWithFormatv("Failed to process thread #{0}.\n", tid);
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -156,3 +153,45 @@ bool CommandObjectIterateOverThreads::BucketThread(
}
return true;
}
+
+bool CommandObjectMultipleThreads::DoExecute(Args &command,
+ CommandReturnObject &result) {
+ Process &process = m_exe_ctx.GetProcessRef();
+
+ std::vector<lldb::tid_t> tids;
+ const size_t num_args = command.GetArgumentCount();
+
+ std::lock_guard<std::recursive_mutex> guard(
+ process.GetThreadList().GetMutex());
+
+ if (num_args > 0 && ::strcmp(command.GetArgumentAtIndex(0), "all") == 0) {
+ for (ThreadSP thread_sp : process.Threads())
+ tids.push_back(thread_sp->GetID());
+ } else {
+ if (num_args == 0) {
+ Thread &thread = m_exe_ctx.GetThreadRef();
+ tids.push_back(thread.GetID());
+ }
+
+ for (size_t i = 0; i < num_args; i++) {
+ uint32_t thread_idx;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(i), thread_idx)) {
+ result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
+ command.GetArgumentAtIndex(i));
+ return false;
+ }
+
+ ThreadSP thread = process.GetThreadList().FindThreadByIndexID(thread_idx);
+
+ if (!thread) {
+ result.AppendErrorWithFormat("no thread with index: \"%s\"\n",
+ command.GetArgumentAtIndex(i));
+ return false;
+ }
+
+ tids.push_back(thread->GetID());
+ }
+ }
+
+ return DoExecuteOnThreads(command, result, tids);
+}