diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
| -rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 113 |
1 files changed, 46 insertions, 67 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index ab047ee926c9..6dc7648f872d 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -160,7 +160,7 @@ public: } protected: - bool DoExecute(Args &launch_args, CommandReturnObject &result) override { + void DoExecute(Args &launch_args, CommandReturnObject &result) override { Debugger &debugger = GetDebugger(); Target *target = debugger.GetSelectedTarget().get(); // If our listener is nullptr, users aren't allows to launch @@ -174,13 +174,13 @@ protected: if (exe_module_sp == nullptr && !target->GetProcessLaunchInfo().GetExecutableFile()) { result.AppendError("no file in target, create a debug target using the " "'target create' command"); - return false; + return; } StateType state = eStateInvalid; if (!StopProcessIfNecessary(m_exe_ctx.GetProcessPtr(), state, result)) - return false; + return; // Determine whether we will disable ASLR or leave it in the default state // (i.e. enabled if the platform supports it). First check if the process @@ -264,9 +264,6 @@ protected: // PushProcessIOHandler(). process_sp->SyncIOHandler(0, std::chrono::seconds(2)); - llvm::StringRef data = stream.GetString(); - if (!data.empty()) - result.AppendMessage(data); // If we didn't have a local executable, then we wouldn't have had an // executable module before launch. if (!exe_module_sp) @@ -282,6 +279,11 @@ protected: exe_module_sp->GetFileSpec().GetPath().c_str(), archname); } result.SetStatus(eReturnStatusSuccessFinishResult); + // This message will refer to an event that happened after the process + // launched. + llvm::StringRef data = stream.GetString(); + if (!data.empty()) + result.AppendMessage(data); result.SetDidChangeProcessState(true); } else { result.AppendError( @@ -290,7 +292,6 @@ protected: } else { result.AppendError(error.AsCString()); } - return result.Succeeded(); } CommandOptionsProcessLaunch m_options; @@ -320,7 +321,7 @@ public: Options *GetOptions() override { return &m_all_options; } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { PlatformSP platform_sp( GetDebugger().GetPlatformList().GetSelectedPlatform()); @@ -334,7 +335,7 @@ protected: Process *process = m_exe_ctx.GetProcessPtr(); if (!StopProcessIfNecessary(process, state, result)) - return false; + return; if (target == nullptr) { // If there isn't a current target create one. @@ -348,7 +349,7 @@ protected: target = new_target_sp.get(); if (target == nullptr || error.Fail()) { result.AppendError(error.AsCString("Error creating target")); - return false; + return; } } @@ -384,7 +385,7 @@ protected: } if (!result.Succeeded()) - return false; + return; // Okay, we're done. Last step is to warn if the executable module has // changed: @@ -429,8 +430,6 @@ protected: ExecutionContext exe_ctx(process_sp); m_interpreter.HandleCommand("process continue", eLazyBoolNo, exe_ctx, result); } - - return result.Succeeded(); } CommandOptionsProcessAttach m_options; @@ -504,8 +503,7 @@ protected: bool m_any_bkpts_specified = false; }; - - 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(); StateType state = process->GetState(); @@ -521,10 +519,10 @@ protected: BreakpointSiteSP bp_site_sp( process->GetBreakpointSiteList().FindByID(bp_site_id)); if (bp_site_sp) { - const size_t num_owners = bp_site_sp->GetNumberOfOwners(); + const size_t num_owners = bp_site_sp->GetNumberOfConstituents(); for (size_t i = 0; i < num_owners; i++) { Breakpoint &bp_ref = - bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint(); + bp_site_sp->GetConstituentAtIndex(i)->GetBreakpoint(); if (!bp_ref.IsInternal()) { bp_ref.SetIgnoreCount(m_options.m_ignore); } @@ -543,13 +541,13 @@ protected: m_options.m_run_to_bkpt_args, target, result, &run_to_bkpt_ids, BreakpointName::Permissions::disablePerm); if (!result.Succeeded()) { - return false; + return; } result.Clear(); if (m_options.m_any_bkpts_specified && run_to_bkpt_ids.GetSize() == 0) { result.AppendError("continue-to breakpoints did not specify any actual " "breakpoints or locations"); - return false; + return; } // First figure out which breakpoints & locations were specified by the @@ -612,7 +610,7 @@ protected: if (!any_enabled) { result.AppendError("at least one of the continue-to breakpoints must " "be enabled."); - return false; + return; } // Also, if you specify BOTH a breakpoint and one of it's locations, @@ -737,7 +735,6 @@ protected: "Process cannot be continued from its current state (%s).\n", StateAsCString(state)); } - return result.Succeeded(); } Options *GetOptions() override { return &m_options; } @@ -809,7 +806,7 @@ public: Options *GetOptions() override { return &m_options; } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); // FIXME: This will be a Command Option: bool keep_stopped; @@ -826,9 +823,7 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendErrorWithFormat("Detach failed: %s\n", error.AsCString()); - return false; } - return result.Succeeded(); } CommandOptions m_options; @@ -894,12 +889,12 @@ public: Options *GetOptions() override { return &m_options; } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { if (command.GetArgumentCount() != 1) { result.AppendErrorWithFormat( "'%s' takes exactly one argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); - return false; + return; } Process *process = m_exe_ctx.GetProcessPtr(); @@ -908,7 +903,7 @@ protected: "Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n", process->GetID()); - return false; + return; } const char *plugin_name = nullptr; @@ -929,9 +924,7 @@ protected: error); if (error.Fail() || process_sp == nullptr) { result.AppendError(error.AsCString("Error connecting to the process")); - return false; } - return true; } CommandOptions m_options; @@ -1032,7 +1025,7 @@ public: Options *GetOptions() override { return &m_options; } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); for (auto &entry : command.entries()) { @@ -1071,7 +1064,6 @@ protected: error.AsCString()); } } - return result.Succeeded(); } CommandOptions m_options; @@ -1115,7 +1107,7 @@ public: } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); for (auto &entry : command.entries()) { @@ -1138,7 +1130,6 @@ protected: } } } - return result.Succeeded(); } }; @@ -1178,13 +1169,13 @@ public: UnixSignalsSP signals = m_exe_ctx.GetProcessPtr()->GetUnixSignals(); int signo = signals->GetFirstSignalNumber(); while (signo != LLDB_INVALID_SIGNAL_NUMBER) { - request.TryCompleteCurrentArg(signals->GetSignalAsCString(signo)); + request.TryCompleteCurrentArg(signals->GetSignalAsStringRef(signo)); signo = signals->GetNextSignalNumber(signo); } } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); if (command.GetArgumentCount() == 1) { @@ -1214,7 +1205,6 @@ protected: "'%s' takes exactly one signal number argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); } - return result.Succeeded(); } }; @@ -1233,11 +1223,11 @@ public: ~CommandObjectProcessInterrupt() override = default; 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 to halt"); - return false; + return; } bool clear_thread_plans = true; @@ -1248,7 +1238,6 @@ protected: result.AppendErrorWithFormat("Failed to halt process: %s\n", error.AsCString()); } - return result.Succeeded(); } }; @@ -1267,11 +1256,11 @@ public: ~CommandObjectProcessKill() override = default; 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 to kill"); - return false; + return; } Status error(process->Destroy(true)); @@ -1281,7 +1270,6 @@ protected: result.AppendErrorWithFormat("Failed to kill process: %s\n", error.AsCString()); } - return result.Succeeded(); } }; @@ -1356,7 +1344,7 @@ public: }; protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { ProcessSP process_sp = m_exe_ctx.GetProcessSP(); if (process_sp) { if (command.GetArgumentCount() == 1) { @@ -1390,10 +1378,7 @@ protected: } } else { result.AppendError("invalid process"); - return false; } - - return result.Succeeded(); } CommandOptions m_options; @@ -1451,7 +1436,7 @@ public: }; protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -1483,7 +1468,7 @@ protected: PlatformSP platform_sp = process->GetTarget().GetPlatform(); if (!platform_sp) { result.AppendError("Couldn'retrieve the target's platform"); - return result.Succeeded(); + return; } auto expected_crash_info = @@ -1491,7 +1476,7 @@ protected: if (!expected_crash_info) { result.AppendError(llvm::toString(expected_crash_info.takeError())); - return result.Succeeded(); + return; } StructuredData::DictionarySP crash_info_sp = *expected_crash_info; @@ -1502,8 +1487,6 @@ protected: crash_info_sp->GetDescription(strm); } } - - return result.Succeeded(); } private: @@ -1635,13 +1618,13 @@ public: str.Printf("=========== ===== ===== ======\n"); } - void PrintSignal(Stream &str, int32_t signo, const char *sig_name, + void PrintSignal(Stream &str, int32_t signo, llvm::StringRef sig_name, const UnixSignalsSP &signals_sp) { bool stop; bool suppress; bool notify; - str.Printf("%-11s ", sig_name); + str.Format("{0, -11} ", sig_name); if (signals_sp->GetSignalInfo(signo, suppress, stop, notify)) { bool pass = !suppress; str.Printf("%s %s %s", (pass ? "true " : "false"), @@ -1668,7 +1651,7 @@ public: { int32_t signo = signals_sp->GetFirstSignalNumber(); while (signo != LLDB_INVALID_SIGNAL_NUMBER) { - PrintSignal(str, signo, signals_sp->GetSignalAsCString(signo), + PrintSignal(str, signo, signals_sp->GetSignalAsStringRef(signo), signals_sp); signo = signals_sp->GetNextSignalNumber(signo); } @@ -1676,7 +1659,7 @@ public: } protected: - bool DoExecute(Args &signal_args, CommandReturnObject &result) override { + void DoExecute(Args &signal_args, CommandReturnObject &result) override { Target &target = GetSelectedOrDummyTarget(); // Any signals that are being set should be added to the Target's @@ -1693,28 +1676,28 @@ protected: !VerifyCommandOptionValue(m_options.stop, stop_action)) { result.AppendError("Invalid argument for command option --stop; must be " "true or false.\n"); - return false; + return; } if (!m_options.notify.empty() && !VerifyCommandOptionValue(m_options.notify, notify_action)) { result.AppendError("Invalid argument for command option --notify; must " "be true or false.\n"); - return false; + return; } if (!m_options.pass.empty() && !VerifyCommandOptionValue(m_options.pass, pass_action)) { result.AppendError("Invalid argument for command option --pass; must be " "true or false.\n"); - return false; + return; } bool no_actions = (stop_action == -1 && pass_action == -1 && notify_action == -1); if (m_options.only_target_values && !no_actions) { result.AppendError("-t is for reporting, not setting, target values."); - return false; + return; } size_t num_args = signal_args.GetArgumentCount(); @@ -1729,7 +1712,7 @@ protected: if (m_options.only_target_values) { target.PrintDummySignals(result.GetOutputStream(), signal_args); result.SetStatus(eReturnStatusSuccessFinishResult); - return true; + return; } // This handles clearing values: @@ -1738,7 +1721,7 @@ protected: if (m_options.dummy) GetDummyTarget().ClearDummySignals(signal_args); result.SetStatus(eReturnStatusSuccessFinishNoResult); - return true; + return; } // This rest handles setting values: @@ -1774,7 +1757,7 @@ protected: if (llvm::to_integer(arg.c_str(), signo)) { result.AppendErrorWithFormat("Can't set signal handling by signal " "number with no process"); - return false; + return; } num_signals_set = num_args; } @@ -1831,8 +1814,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); else result.SetStatus(eReturnStatusFailed); - - return result.Succeeded(); } CommandOptions m_options; @@ -1873,7 +1854,7 @@ public: ~CommandObjectProcessTraceStop() override = default; - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { ProcessSP process_sp = m_exe_ctx.GetProcessSP(); TraceSP trace_sp = process_sp->GetTarget().GetTrace(); @@ -1882,8 +1863,6 @@ public: result.AppendError(toString(std::move(err))); else result.SetStatus(eReturnStatusSuccessFinishResult); - - return result.Succeeded(); } }; |
