diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectThread.cpp | 140 |
1 files changed, 63 insertions, 77 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 64f3edc..a9f5a4f 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -412,7 +412,7 @@ public: Options *GetOptions() override { return &m_all_options; } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); bool synchronous_execution = m_interpreter.GetSynchronous(); @@ -424,7 +424,7 @@ protected: if (thread == nullptr) { result.AppendError("no selected thread in process"); - return false; + return; } } else { const char *thread_idx_cstr = command.GetArgumentAtIndex(0); @@ -433,7 +433,7 @@ protected: if (!llvm::to_integer(thread_idx_cstr, step_thread_idx)) { result.AppendErrorWithFormat("invalid thread index '%s'.\n", thread_idx_cstr); - return false; + return; } thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get(); @@ -441,20 +441,20 @@ protected: result.AppendErrorWithFormat( "Thread index %u is out of range (valid values are 0 - %u).\n", step_thread_idx, num_threads); - return false; + return; } } if (m_step_type == eStepTypeScripted) { if (m_class_options.GetName().empty()) { result.AppendErrorWithFormat("empty class name for scripted step."); - return false; + return; } else if (!GetDebugger().GetScriptInterpreter()->CheckObjectExists( m_class_options.GetName().c_str())) { result.AppendErrorWithFormat( "class for scripted step: \"%s\" does not exist.", m_class_options.GetName().c_str()); - return false; + return; } } @@ -462,7 +462,7 @@ protected: m_step_type != eStepTypeInto) { result.AppendErrorWithFormat( "end line option is only valid for step into"); - return false; + return; } const bool abort_other_plans = false; @@ -494,14 +494,14 @@ protected: error)) { result.AppendErrorWithFormat("invalid end-line option: %s.", error.AsCString()); - return false; + return; } } else if (m_options.m_end_line_is_block_end) { Status error; Block *block = frame->GetSymbolContext(eSymbolContextBlock).block; if (!block) { result.AppendErrorWithFormat("Could not find the current block."); - return false; + return; } AddressRange block_range; @@ -510,7 +510,7 @@ protected: if (!block_range.GetBaseAddress().IsValid()) { result.AppendErrorWithFormat( "Could not find the current block address."); - return false; + return; } lldb::addr_t pc_offset_in_block = pc_address.GetFileAddress() - @@ -569,7 +569,7 @@ protected: new_plan_status); } else { result.AppendError("step type is not supported"); - return false; + return; } // If we got a new plan, then set it to be a controlling plan (User level @@ -600,7 +600,7 @@ protected: if (!error.Success()) { result.AppendMessage(error.AsCString()); - return false; + return; } // There is a race condition where this thread will return up the call @@ -624,7 +624,6 @@ protected: } else { result.SetError(new_plan_status); } - return result.Succeeded(); } StepType m_step_type; @@ -672,13 +671,13 @@ public: nullptr); } - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { bool synchronous_execution = m_interpreter.GetSynchronous(); Process *process = m_exe_ctx.GetProcessPtr(); if (process == nullptr) { result.AppendError("no process exists. Cannot continue"); - return false; + return; } StateType state = process->GetState(); @@ -698,7 +697,7 @@ public: if (entry.ref().getAsInteger(0, thread_idx)) { result.AppendErrorWithFormat( "invalid thread index argument: \"%s\".\n", entry.c_str()); - return false; + return; } Thread *thread = process->GetThreadList().FindThreadByIndexID(thread_idx).get(); @@ -708,13 +707,13 @@ public: } else { result.AppendErrorWithFormat("invalid thread index %u.\n", thread_idx); - return false; + return; } } if (resume_threads.empty()) { result.AppendError("no valid thread indexes were specified"); - return false; + return; } else { if (resume_threads.size() == 1) result.AppendMessageWithFormat("Resuming thread: "); @@ -753,7 +752,7 @@ public: Thread *current_thread = GetDefaultThread(); if (current_thread == nullptr) { result.AppendError("the process doesn't have a current thread"); - return false; + return; } // Set the actions that the threads should each take when resuming for (uint32_t idx = 0; idx < num_threads; ++idx) { @@ -801,8 +800,6 @@ public: "Process cannot be continued from its current state (%s).\n", StateAsCString(state)); } - - return result.Succeeded(); } }; @@ -920,7 +917,7 @@ public: Options *GetOptions() override { return &m_options; } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { bool synchronous_execution = m_interpreter.GetSynchronous(); Target *target = &GetSelectedTarget(); @@ -939,14 +936,14 @@ protected: if (!llvm::to_integer(command.GetArgumentAtIndex(i), line_number)) { result.AppendErrorWithFormat("invalid line number: '%s'.\n", command.GetArgumentAtIndex(i)); - return false; + return; } else line_numbers.push_back(line_number); } } else if (m_options.m_until_addrs.empty()) { result.AppendErrorWithFormat("No line number or address provided:\n%s", GetSyntax().str().c_str()); - return false; + return; } if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID) { @@ -962,7 +959,7 @@ protected: result.AppendErrorWithFormat( "Thread index %u is out of range (valid values are 0 - %u).\n", m_options.m_thread_idx, num_threads); - return false; + return; } const bool abort_other_plans = false; @@ -973,7 +970,7 @@ protected: result.AppendErrorWithFormat( "Frame index %u is out of range for thread id %" PRIu64 ".\n", m_options.m_frame_idx, thread->GetID()); - return false; + return; } ThreadPlanSP new_plan_sp; @@ -991,7 +988,7 @@ protected: result.AppendErrorWithFormat("Failed to resolve the line table for " "frame %u of thread id %" PRIu64 ".\n", m_options.m_frame_idx, thread->GetID()); - return false; + return; } LineEntry function_start; @@ -1003,7 +1000,7 @@ protected: if (!sc.function) { result.AppendErrorWithFormat("Have debug information but no " "function info - can't get until range."); - return false; + return; } AddressRange fun_addr_range = sc.function->GetAddressRange(); @@ -1067,7 +1064,7 @@ protected: result.AppendErrorWithFormat( "Until target outside of the current function.\n"); - return false; + return; } new_plan_sp = thread->QueueThreadPlanForStepUntil( @@ -1083,20 +1080,20 @@ protected: new_plan_sp->SetOkayToDiscard(false); } else { result.SetError(new_plan_status); - return false; + return; } } else { result.AppendErrorWithFormat("Frame index %u of thread id %" PRIu64 " has no debug information.\n", m_options.m_frame_idx, thread->GetID()); - return false; + return; } if (!process->GetThreadList().SetSelectedThreadByID(thread->GetID())) { result.AppendErrorWithFormat( "Failed to set the selected thread to thread id %" PRIu64 ".\n", thread->GetID()); - return false; + return; } StreamString stream; @@ -1125,7 +1122,6 @@ protected: error.AsCString()); } } - return result.Succeeded(); } CommandOptions m_options; @@ -1170,23 +1166,23 @@ public: } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); if (process == nullptr) { result.AppendError("no process"); - return false; + return; } else if (command.GetArgumentCount() != 1) { result.AppendErrorWithFormat( "'%s' takes exactly one thread index argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); - return false; + return; } uint32_t index_id; if (!llvm::to_integer(command.GetArgumentAtIndex(0), index_id)) { result.AppendErrorWithFormat("Invalid thread index '%s'", command.GetArgumentAtIndex(0)); - return false; + return; } Thread *new_thread = @@ -1194,13 +1190,11 @@ protected: if (new_thread == nullptr) { result.AppendErrorWithFormat("invalid thread #%s.\n", command.GetArgumentAtIndex(0)); - return false; + return; } process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true); result.SetStatus(eReturnStatusSuccessFinishNoResult); - - return result.Succeeded(); } }; @@ -1221,7 +1215,7 @@ public: ~CommandObjectThreadList() override = default; protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); result.SetStatus(eReturnStatusSuccessFinishNoResult); Process *process = m_exe_ctx.GetProcessPtr(); @@ -1232,7 +1226,6 @@ protected: process->GetStatus(strm); process->GetThreadStatus(strm, only_threads_with_stop_reason, start_frame, num_frames, num_frames_with_source, false); - return result.Succeeded(); } }; @@ -1511,7 +1504,7 @@ public: Options *GetOptions() override { return &m_options; } protected: - bool DoExecute(llvm::StringRef command, + void DoExecute(llvm::StringRef command, CommandReturnObject &result) override { // I am going to handle this by hand, because I don't want you to have to // say: @@ -1539,7 +1532,7 @@ protected: "Could not select 0th frame after unwinding expression."); } } - return result.Succeeded(); + return; } ValueObjectSP return_valobj_sp; @@ -1549,7 +1542,7 @@ protected: if (frame_sp->IsInlined()) { result.AppendError("Don't know how to return from inlined frames."); - return false; + return; } if (!command.empty()) { @@ -1570,7 +1563,7 @@ protected: else result.AppendErrorWithFormat( "Unknown error evaluating result expression."); - return false; + return; } } @@ -1582,11 +1575,10 @@ protected: result.AppendErrorWithFormat( "Error returning from frame %d of thread %d: %s.", frame_idx, thread_sp->GetIndexID(), error.AsCString()); - return false; + return; } result.SetStatus(eReturnStatusSuccessFinishResult); - return true; } CommandOptions m_options; @@ -1667,7 +1659,7 @@ public: Options *GetOptions() override { return &m_options; } protected: - bool DoExecute(Args &args, CommandReturnObject &result) override { + void DoExecute(Args &args, CommandReturnObject &result) override { RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext(); StackFrame *frame = m_exe_ctx.GetFramePtr(); Thread *thread = m_exe_ctx.GetThreadPtr(); @@ -1682,13 +1674,13 @@ protected: lldb::addr_t callAddr = dest.GetCallableLoadAddress(target); if (callAddr == LLDB_INVALID_ADDRESS) { result.AppendErrorWithFormat("Invalid destination address."); - return false; + return; } if (!reg_ctx->SetPC(callAddr)) { result.AppendErrorWithFormat("Error changing PC value for thread %d.", thread->GetIndexID()); - return false; + return; } } else { // Pick either the absolute line, or work out a relative one. @@ -1704,7 +1696,7 @@ protected: if (!file) { result.AppendErrorWithFormat( "No source file available for the current location."); - return false; + return; } std::string warnings; @@ -1712,7 +1704,7 @@ protected: if (err.Fail()) { result.SetError(err); - return false; + return; } if (!warnings.empty()) @@ -1720,7 +1712,6 @@ protected: } result.SetStatus(eReturnStatusSuccessFinishResult); - return true; } CommandOptions m_options; @@ -1804,7 +1795,7 @@ public: Options *GetOptions() override { return &m_options; } - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { // If we are reporting all threads, dispatch to the Process to do that: if (command.GetArgumentCount() == 0 && m_options.m_tids.empty()) { Stream &strm = result.GetOutputStream(); @@ -1814,7 +1805,7 @@ public: m_exe_ctx.GetProcessPtr()->DumpThreadPlans( strm, desc_level, m_options.m_internal, true, m_options.m_unreported); result.SetStatus(eReturnStatusSuccessFinishResult); - return true; + return; } else { // Do any TID's that the user may have specified as TID, then do any // Thread Indexes... @@ -1829,7 +1820,7 @@ public: if (!success) { result.AppendError("Error dumping plans:"); result.AppendError(tmp_strm.GetString()); - return false; + return; } // Otherwise, add our data to the output: result.GetOutputStream() << tmp_strm.GetString(); @@ -1899,13 +1890,13 @@ public: m_exe_ctx.GetThreadPtr()->AutoCompleteThreadPlans(request); } - bool DoExecute(Args &args, CommandReturnObject &result) override { + void DoExecute(Args &args, CommandReturnObject &result) override { Thread *thread = m_exe_ctx.GetThreadPtr(); if (args.GetArgumentCount() != 1) { result.AppendErrorWithFormat("Too many arguments, expected one - the " "thread plan index - but got %zu.", args.GetArgumentCount()); - return false; + return; } uint32_t thread_plan_idx; @@ -1913,23 +1904,21 @@ public: result.AppendErrorWithFormat( "Invalid thread index: \"%s\" - should be unsigned int.", args.GetArgumentAtIndex(0)); - return false; + return; } if (thread_plan_idx == 0) { result.AppendErrorWithFormat( "You wouldn't really want me to discard the base thread plan."); - return false; + return; } if (thread->DiscardUserThreadPlansUpToIndex(thread_plan_idx)) { result.SetStatus(eReturnStatusSuccessFinishNoResult); - return true; } else { result.AppendErrorWithFormat( "Could not find User thread plan with index %s.", args.GetArgumentAtIndex(0)); - return false; } } }; @@ -1965,13 +1954,13 @@ public: ~CommandObjectThreadPlanPrune() override = default; - bool DoExecute(Args &args, CommandReturnObject &result) override { + void DoExecute(Args &args, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); if (args.GetArgumentCount() == 0) { process->PruneThreadPlans(); result.SetStatus(eReturnStatusSuccessFinishNoResult); - return true; + return; } const size_t num_args = args.GetArgumentCount(); @@ -1984,16 +1973,15 @@ public: if (!llvm::to_integer(args.GetArgumentAtIndex(i), tid)) { result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n", args.GetArgumentAtIndex(i)); - return false; + return; } if (!process->PruneThreadPlansForTID(tid)) { result.AppendErrorWithFormat("Could not find unreported tid: \"%s\"\n", args.GetArgumentAtIndex(i)); - return false; + return; } } result.SetStatus(eReturnStatusSuccessFinishNoResult); - return true; } }; @@ -2187,11 +2175,11 @@ public: Options *GetOptions() override { return &m_options; } protected: - bool DoExecute(Args &args, CommandReturnObject &result) override { + void DoExecute(Args &args, CommandReturnObject &result) override { ThreadSP thread_sp = GetSingleThreadFromArgs(m_exe_ctx, args, result); if (!thread_sp) { result.AppendError("invalid thread\n"); - return false; + return; } llvm::Expected<TraceCursorSP> cursor_or_error = @@ -2199,7 +2187,7 @@ protected: if (!cursor_or_error) { result.AppendError(llvm::toString(cursor_or_error.takeError())); - return false; + return; } TraceCursorSP &cursor_sp = *cursor_or_error; @@ -2217,7 +2205,6 @@ protected: m_options.m_dumper_options); dumper.DumpFunctionCalls(); - return true; } CommandOptions m_options; @@ -2371,11 +2358,11 @@ public: } protected: - bool DoExecute(Args &args, CommandReturnObject &result) override { + void DoExecute(Args &args, CommandReturnObject &result) override { ThreadSP thread_sp = GetSingleThreadFromArgs(m_exe_ctx, args, result); if (!thread_sp) { result.AppendError("invalid thread\n"); - return false; + return; } if (m_options.m_continue && m_last_id) { @@ -2390,14 +2377,14 @@ protected: if (!cursor_or_error) { result.AppendError(llvm::toString(cursor_or_error.takeError())); - return false; + return; } TraceCursorSP &cursor_sp = *cursor_or_error; if (m_options.m_dumper_options.id && !cursor_sp->HasId(*m_options.m_dumper_options.id)) { result.AppendError("invalid instruction id\n"); - return false; + return; } std::optional<StreamFile> out_file; @@ -2419,7 +2406,6 @@ protected: m_options.m_dumper_options); m_last_id = dumper.DumpInstructions(m_options.m_count); - return true; } CommandOptions m_options; |