summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2014-10-21 01:00:42 +0000
committerGreg Clayton <gclayton@apple.com>2014-10-21 01:00:42 +0000
commitdc6224e0a3ce2b097f0a631de9ae1960f175dfe6 (patch)
tree7364aee6be1c2bddee56bcabeab0ca59de7fb2c5 /lldb/source/Commands/CommandObjectProcess.cpp
parentf16a66973c04f56eb5068fe407ad75a3e09ee00a (diff)
downloadbcm5719-llvm-dc6224e0a3ce2b097f0a631de9ae1960f175dfe6.tar.gz
bcm5719-llvm-dc6224e0a3ce2b097f0a631de9ae1960f175dfe6.zip
Make the "synchronous" mode actually work without race conditions.
There were many issues with synchronous mode that we discovered when started to try and add a "batch" mode. There was a race condition where the event handling thread might consume events when in sync mode and other times the Process::WaitForProcessToStop() would consume them. This also led to places where the Process IO handler might or might not get popped when it needed to be. llvm-svn: 220254
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 6536c6ef169..b5ca44f3d6e 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -258,8 +258,9 @@ protected:
// Save the arguments for subsequent runs in the current target.
target->SetRunArguments (launch_args);
}
-
- Error error = target->Launch(debugger.GetListener(), m_options.launch_info);
+
+ StreamString stream;
+ Error error = target->Launch(debugger.GetListener(), m_options.launch_info, &stream);
if (error.Success())
{
@@ -267,6 +268,8 @@ protected:
ProcessSP process_sp (target->GetProcessSP());
if (process_sp)
{
+ if (stream.GetData())
+ result.AppendMessage(stream.GetData());
result.AppendMessageWithFormat ("Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(), exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
result.SetStatus (eReturnStatusSuccessFinishResult);
result.SetDidChangeProcessState (true);
@@ -564,15 +567,18 @@ protected:
if (error.Success())
{
result.SetStatus (eReturnStatusSuccessContinuingNoResult);
- StateType state = process->WaitForProcessToStop (NULL, NULL, false, listener_sp.get());
+ StreamString stream;
+ StateType state = process->WaitForProcessToStop (NULL, NULL, false, listener_sp.get(), &stream);
process->RestoreProcessEvents();
result.SetDidChangeProcessState (true);
+ if (stream.GetData())
+ result.AppendMessage(stream.GetData());
+
if (state == eStateStopped)
{
- result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
@@ -791,7 +797,12 @@ protected:
}
}
- Error error(process->Resume());
+ StreamString stream;
+ Error error;
+ if (synchronous_execution)
+ error = process->ResumeSynchronous (&stream);
+ else
+ error = process->Resume ();
if (error.Success())
{
@@ -803,10 +814,11 @@ protected:
result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
if (synchronous_execution)
{
- state = process->WaitForProcessToStop (NULL);
+ // If any state changed events had anything to say, add that to the result
+ if (stream.GetData())
+ result.AppendMessage(stream.GetData());
result.SetDidChangeProcessState (true);
- result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
OpenPOWER on IntegriCloud