aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-01-29 07:10:55 +0000
committerGreg Clayton <gclayton@apple.com>2011-01-29 07:10:55 +0000
commit513c26ce9ddebe5adbcb068e88b452a904ee6f8d (patch)
tree4b06c857d67e39f2202c1fee7af2237029b93c8f /lldb/source/Commands/CommandObjectProcess.cpp
parentfd4834061c5b1e6e056d0d53da72980ae44b638e (diff)
downloadllvm-513c26ce9ddebe5adbcb068e88b452a904ee6f8d.zip
llvm-513c26ce9ddebe5adbcb068e88b452a904ee6f8d.tar.gz
llvm-513c26ce9ddebe5adbcb068e88b452a904ee6f8d.tar.bz2
Finished up the async attach support. This allows us to request to attach
by name or by pid (with or without waiting for a process to launch) and catch the response asynchronously. llvm-svn: 124530
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 42bc4af..3d863b7 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -167,10 +167,14 @@ public:
Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
if (process && process->IsAlive())
{
- if (!m_interpreter.Confirm ("There is a running process, kill it and restart?", true))
+ char message[1024];
+ if (process->GetState() == eStateAttaching)
+ ::strncpy (message, "There is a pending attach, abort it and launch a new process?", sizeof(message));
+ else
+ ::strncpy (message, "There is a running process, kill it and restart?", sizeof(message));
+
+ if (!m_interpreter.Confirm (message, true))
{
- result.AppendErrorWithFormat ("Process %u is currently being debugged, restart cancelled.\n",
- process->GetID());
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -623,7 +627,7 @@ public:
return false;
}
- m_interpreter.GetDebugger().GetOutputStream().Printf("Waiting to attach to a process named \"%s\".\n", wait_name);
+ result.AppendMessageWithFormat("Waiting to attach to a process named \"%s\".\n", wait_name);
error = process->Attach (wait_name, m_options.waitfor);
if (error.Success())
{
@@ -652,7 +656,6 @@ public:
else
{
result.SetDidChangeProcessState (true);
- result.AppendMessageWithFormat ("Starting to attach to process.");
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
}
@@ -712,7 +715,6 @@ public:
else
{
result.SetDidChangeProcessState (true);
- result.AppendMessageWithFormat ("Starting to attach to process.");
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
}
@@ -731,18 +733,20 @@ public:
if (result.Succeeded())
{
// Okay, we're done. Last step is to warn if the executable module has changed:
+ char new_path[PATH_MAX];
if (!old_exec_module_sp)
{
- char new_path[PATH_MAX + 1];
- target->GetExecutableModule()->GetFileSpec().GetPath(new_path, PATH_MAX);
-
- result.AppendMessageWithFormat("Executable module set to \"%s\".\n",
- new_path);
+ // We might not have a module if we attached to a raw pid...
+ ModuleSP new_module_sp (target->GetExecutableModule());
+ if (new_module_sp)
+ {
+ new_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
+ result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
+ }
}
else if (old_exec_module_sp->GetFileSpec() != target->GetExecutableModule()->GetFileSpec())
{
- char old_path[PATH_MAX + 1];
- char new_path[PATH_MAX + 1];
+ char old_path[PATH_MAX];
old_exec_module_sp->GetFileSpec().GetPath(old_path, PATH_MAX);
target->GetExecutableModule()->GetFileSpec().GetPath (new_path, PATH_MAX);