summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-02-20 20:59:47 +0000
committerGreg Clayton <gclayton@apple.com>2015-02-20 20:59:47 +0000
commit35824e36f5f3f39c6c4220ebd26b414a2b4e6350 (patch)
tree7c7f14236af581d1f1f666827ac32fabca6c4045 /lldb/source/Target/Process.cpp
parent9ecaa174d69bc22dc9a5896457915e0518fe9abc (diff)
downloadbcm5719-llvm-35824e36f5f3f39c6c4220ebd26b414a2b4e6350.tar.gz
bcm5719-llvm-35824e36f5f3f39c6c4220ebd26b414a2b4e6350.zip
Avoid a race condition when loading core files where the process might still be handling the eStateStopped event we post to the private state thread causing us to return from SBTarget::LoadCore() before the process is ready to have API calls used on it.
This fixes a crasher that could happen when loading core files from scripts. llvm-svn: 230060
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r--lldb/source/Target/Process.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index c4eccfc78c3..88a76ff79a9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -3163,6 +3163,9 @@ Process::LoadCore ()
Error error = DoLoadCore();
if (error.Success())
{
+ Listener listener ("lldb.process.load_core_listener");
+ HijackPrivateProcessEvents(&listener);
+
if (PrivateStateThreadIsValid ())
ResumePrivateStateThread ();
else
@@ -3183,7 +3186,20 @@ Process::LoadCore ()
// show all of the threads in the core file and explore the crashed
// state.
SetPrivateState (eStateStopped);
-
+
+ // Wait indefinitely for a stopped event since we just posted one above...
+ lldb::EventSP event_sp;
+ listener.WaitForEvent (NULL, event_sp);
+ StateType state = ProcessEventData::GetStateFromEvent(event_sp.get());
+
+ if (!StateIsStoppedState (state, false))
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ if (log)
+ log->Printf("Process::Halt() failed to stop, state is: %s", StateAsCString(state));
+ error.SetErrorString ("Did not get stopped event after loading the core file.");
+ }
+ RestorePrivateProcessEvents ();
}
return error;
}
OpenPOWER on IntegriCloud