summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp90
1 files changed, 29 insertions, 61 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 293b762295f..b7f894f6dcf 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1051,78 +1051,46 @@ protected:
bool
DoExecute (Args& command, CommandReturnObject &result) override
{
-
- TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
- Error error;
- Process *process = m_exe_ctx.GetProcessPtr();
- if (process)
+ if (command.GetArgumentCount() != 1)
{
- if (process->IsAlive())
- {
- result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
- process->GetID());
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
+ m_cmd_name.c_str(),
+ m_cmd_syntax.c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
+
- if (!target_sp)
+ Process *process = m_exe_ctx.GetProcessPtr();
+ if (process && process->IsAlive())
{
- // If there isn't a current target create one.
-
- error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
- NULL,
- NULL,
- false,
- NULL, // No platform options
- target_sp);
- if (!target_sp || error.Fail())
- {
- result.AppendError(error.AsCString("Error creating target"));
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target_sp.get());
+ result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
+ process->GetID());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
-
- if (command.GetArgumentCount() == 1)
- {
- const char *plugin_name = NULL;
- if (!m_options.plugin_name.empty())
- plugin_name = m_options.plugin_name.c_str();
- const char *remote_url = command.GetArgumentAtIndex(0);
- process = target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
-
- if (process)
- {
- error = process->ConnectRemote (process->GetTarget().GetDebugger().GetOutputFile().get(), remote_url);
+ const char *plugin_name = nullptr;
+ if (!m_options.plugin_name.empty())
+ plugin_name = m_options.plugin_name.c_str();
- if (error.Fail())
- {
- result.AppendError(error.AsCString("Remote connect failed"));
- result.SetStatus (eReturnStatusFailed);
- target_sp->DeleteCurrentProcess();
- return false;
- }
- }
- else
- {
- result.AppendErrorWithFormat ("Unable to find process plug-in for remote URL '%s'.\nPlease specify a process plug-in name with the --plugin option, or specify an object file using the \"file\" command.\n",
- remote_url);
- result.SetStatus (eReturnStatusFailed);
- }
- }
- else
+ Error error;
+ Debugger& debugger = m_interpreter.GetDebugger();
+ PlatformSP platform_sp = m_interpreter.GetPlatform(true);
+ ProcessSP process_sp = platform_sp->ConnectProcess(command.GetArgumentAtIndex(0),
+ plugin_name,
+ debugger,
+ debugger.GetSelectedTarget().get(),
+ error);
+ if (error.Fail() || process_sp == nullptr)
{
- result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
- m_cmd_name.c_str(),
- m_cmd_syntax.c_str());
+ result.AppendError(error.AsCString("Error connecting to the process"));
result.SetStatus (eReturnStatusFailed);
+ return false;
}
- return result.Succeeded();
+ return true;
}
-
+
CommandOptions m_options;
};
OpenPOWER on IntegriCloud