diff options
author | Pete Lawrence <plawrence@apple.com> | 2023-10-30 10:21:00 -1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 13:21:00 -0700 |
commit | 92d8a28cc665d73d9d679b8c014dd04f95d1df18 (patch) | |
tree | 19b3a218ad57e05a911da01c0f4f80ca3c0a4bd4 /lldb/source/Commands/CommandObjectThreadUtil.cpp | |
parent | 2446439f51cf0d2dfb11c823436a930de7a4b8a2 (diff) | |
download | llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.zip llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.tar.gz llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.tar.bz2 |
[lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (#69991)
[lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` to return
`void` instead of ~~`bool`~~
Justifications:
- The code doesn't ultimately apply the `true`/`false` return values.
- The methods already pass around a `CommandReturnObject`, typically
with a `result` parameter.
- Each command return object already contains:
- A more precise status
- The error code(s) that apply to that status
Part 1 refactors the `CommandObject::Execute(...)` method.
- See
[https://github.com/llvm/llvm-project/pull/69989](https://github.com/llvm/llvm-project/pull/69989)
rdar://117378957
Diffstat (limited to 'lldb/source/Commands/CommandObjectThreadUtil.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectThreadUtil.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lldb/source/Commands/CommandObjectThreadUtil.cpp b/lldb/source/Commands/CommandObjectThreadUtil.cpp index 504d5fa..d7fa419 100644 --- a/lldb/source/Commands/CommandObjectThreadUtil.cpp +++ b/lldb/source/Commands/CommandObjectThreadUtil.cpp @@ -34,16 +34,16 @@ CommandObjectMultipleThreads::CommandObjectMultipleThreads( m_arguments.push_back({thread_arg}); } -bool CommandObjectIterateOverThreads::DoExecute(Args &command, +void CommandObjectIterateOverThreads::DoExecute(Args &command, CommandReturnObject &result) { result.SetStatus(m_success_return); bool all_threads = false; if (command.GetArgumentCount() == 0) { Thread *thread = m_exe_ctx.GetThreadPtr(); - if (!thread || !HandleOneThread(thread->GetID(), result)) - return false; - return result.Succeeded(); + if (thread) + HandleOneThread(thread->GetID(), result); + return; } else if (command.GetArgumentCount() == 1) { all_threads = ::strcmp(command.GetArgumentAtIndex(0), "all") == 0; m_unique_stacks = ::strcmp(command.GetArgumentAtIndex(0), "unique") == 0; @@ -71,7 +71,7 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command, if (!llvm::to_integer(command.GetArgumentAtIndex(i), thread_idx)) { result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n", command.GetArgumentAtIndex(i)); - return false; + return; } ThreadSP thread = @@ -80,7 +80,7 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command, if (!thread) { result.AppendErrorWithFormat("no thread with index: \"%s\"\n", command.GetArgumentAtIndex(i)); - return false; + return; } tids.push_back(thread->GetID()); @@ -92,7 +92,7 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command, std::set<UniqueStack> unique_stacks; for (const lldb::tid_t &tid : tids) { if (!BucketThread(tid, unique_stacks, result)) { - return false; + return; } } @@ -114,7 +114,7 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command, ThreadSP thread = process->GetThreadList().FindThreadByIndexID( representative_thread_id); if (!HandleOneThread(thread->GetID(), result)) { - return false; + return; } } } else { @@ -124,12 +124,11 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command, result.AppendMessage(""); if (!HandleOneThread(tid, result)) - return false; + return; ++idx; } } - return result.Succeeded(); } bool CommandObjectIterateOverThreads::BucketThread( @@ -167,7 +166,7 @@ bool CommandObjectIterateOverThreads::BucketThread( return true; } -bool CommandObjectMultipleThreads::DoExecute(Args &command, +void CommandObjectMultipleThreads::DoExecute(Args &command, CommandReturnObject &result) { Process &process = m_exe_ctx.GetProcessRef(); @@ -191,7 +190,7 @@ bool CommandObjectMultipleThreads::DoExecute(Args &command, if (!llvm::to_integer(command.GetArgumentAtIndex(i), thread_idx)) { result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n", command.GetArgumentAtIndex(i)); - return false; + return; } ThreadSP thread = process.GetThreadList().FindThreadByIndexID(thread_idx); @@ -199,12 +198,12 @@ bool CommandObjectMultipleThreads::DoExecute(Args &command, if (!thread) { result.AppendErrorWithFormat("no thread with index: \"%s\"\n", command.GetArgumentAtIndex(i)); - return false; + return; } tids.push_back(thread->GetID()); } } - return DoExecuteOnThreads(command, result, tids); + DoExecuteOnThreads(command, result, tids); } |