summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/ExecutionContext.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-02-21 00:09:25 +0000
committerGreg Clayton <gclayton@apple.com>2012-02-21 00:09:25 +0000
commit1ac04c308832f7a9b2e07e360f07c82f7cb2a02c (patch)
treebb908a56f1d08a946f4f25aa7b4b762066e1ec57 /lldb/source/Target/ExecutionContext.cpp
parent3508a0054301ef24b8d8619351788698bcd97620 (diff)
downloadbcm5719-llvm-1ac04c308832f7a9b2e07e360f07c82f7cb2a02c.tar.gz
bcm5719-llvm-1ac04c308832f7a9b2e07e360f07c82f7cb2a02c.zip
Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptr
objects for the backlink to the lldb_private::Process. The issues we were running into before was someone was holding onto a shared pointer to a lldb_private::Thread for too long, and the lldb_private::Process parent object would get destroyed and the lldb_private::Thread had a "Process &m_process" member which would just treat whatever memory that used to be a Process as a valid Process. This was mostly happening for lldb_private::StackFrame objects that had a member like "Thread &m_thread". So this completes the internal strong/weak changes. Documented the ExecutionContext and ExecutionContextRef classes so that our LLDB developers can understand when and where to use ExecutionContext and ExecutionContextRef objects. llvm-svn: 151009
Diffstat (limited to 'lldb/source/Target/ExecutionContext.cpp')
-rw-r--r--lldb/source/Target/ExecutionContext.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp
index e284438eee8..3e0731d9c0e 100644
--- a/lldb/source/Target/ExecutionContext.cpp
+++ b/lldb/source/Target/ExecutionContext.cpp
@@ -72,6 +72,50 @@ ExecutionContext::ExecutionContext (const lldb::StackFrameSP &frame_sp) :
SetContext (frame_sp);
}
+ExecutionContext::ExecutionContext (const lldb::TargetWP &target_wp, bool get_process) :
+ m_target_sp (),
+ m_process_sp (),
+ m_thread_sp (),
+ m_frame_sp ()
+{
+ lldb::TargetSP target_sp(target_wp.lock());
+ if (target_sp)
+ SetContext (target_sp, get_process);
+}
+
+ExecutionContext::ExecutionContext (const lldb::ProcessWP &process_wp) :
+ m_target_sp (),
+ m_process_sp (),
+ m_thread_sp (),
+ m_frame_sp ()
+{
+ lldb::ProcessSP process_sp(process_wp.lock());
+ if (process_sp)
+ SetContext (process_sp);
+}
+
+ExecutionContext::ExecutionContext (const lldb::ThreadWP &thread_wp) :
+ m_target_sp (),
+ m_process_sp (),
+ m_thread_sp (),
+ m_frame_sp ()
+{
+ lldb::ThreadSP thread_sp(thread_wp.lock());
+ if (thread_sp)
+ SetContext (thread_sp);
+}
+
+ExecutionContext::ExecutionContext (const lldb::StackFrameWP &frame_wp) :
+ m_target_sp (),
+ m_process_sp (),
+ m_thread_sp (),
+ m_frame_sp ()
+{
+ lldb::StackFrameSP frame_sp(frame_wp.lock());
+ if (frame_sp)
+ SetContext (frame_sp);
+}
+
ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_frame) :
m_target_sp (t->shared_from_this()),
m_process_sp (),
@@ -208,28 +252,36 @@ ExecutionContext::GetBestExecutionContextScope () const
Target &
ExecutionContext::GetTargetRef () const
{
+#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
assert (m_target_sp.get());
+#endif
return *m_target_sp;
}
Process &
ExecutionContext::GetProcessRef () const
{
+#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
assert (m_process_sp.get());
+#endif
return *m_process_sp;
}
Thread &
ExecutionContext::GetThreadRef () const
{
+#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
assert (m_thread_sp.get());
+#endif
return *m_thread_sp;
}
StackFrame &
ExecutionContext::GetFrameRef () const
{
+#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
assert (m_frame_sp.get());
+#endif
return *m_frame_sp;
}
@@ -324,7 +376,7 @@ ExecutionContext::SetContext (const lldb::ThreadSP &thread_sp)
m_thread_sp = thread_sp;
if (thread_sp)
{
- m_process_sp = thread_sp->GetProcess().shared_from_this();
+ m_process_sp = thread_sp->GetProcess();
if (m_process_sp)
m_target_sp = m_process_sp->GetTarget().shared_from_this();
else
@@ -346,7 +398,7 @@ ExecutionContext::SetContext (const lldb::StackFrameSP &frame_sp)
m_thread_sp = frame_sp->CalculateThread();
if (m_thread_sp)
{
- m_process_sp = m_thread_sp->GetProcess().shared_from_this();
+ m_process_sp = m_thread_sp->GetProcess();
if (m_process_sp)
m_target_sp = m_process_sp->GetTarget().shared_from_this();
else
OpenPOWER on IntegriCloud