From 5f7ddb1456d5b926e85710da690bf548ef0c9fc8 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 22 Aug 2021 21:00:43 +0200 Subject: Merge llvm-project main llvmorg-13-init-16847-g88e66fa60ae5 This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-13-init-16847-g88e66fa60ae5, the last commit before the upstream release/13.x branch was created. PR: 258209 (cherry picked from commit fe6060f10f634930ff71b7c50291ddc610da2475) --- .../source/Commands/CommandObjectThreadUtil.cpp | 45 ++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'contrib/llvm-project/lldb/source/Commands/CommandObjectThreadUtil.cpp') 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 tids; + const size_t num_args = command.GetArgumentCount(); + + std::lock_guard 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); +} -- cgit v1.2.3