[Lldb-commits] [lldb] r119675 - in /lldb/trunk: include/lldb/Target/Thread.h lldb.xcodeproj/project.pbxproj source/Expression/ClangFunction.cpp source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp source/Target/Thread.cpp source/Target/ThreadPlanBase.cpp
Jim Ingham
jingham at apple.com
Wed Nov 17 18:47:08 PST 2010
Author: jingham
Date: Wed Nov 17 20:47:07 2010
New Revision: 119675
URL: http://llvm.org/viewvc/llvm-project?rev=119675&view=rev
Log:
The thread plan destructors may call Thread virtual methods. That means they have to get cleaned up in the derived class's destructor. Make sure that happens.
Modified:
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Expression/ClangFunction.cpp
lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/Target/ThreadPlanBase.cpp
Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=119675&r1=119674&r2=119675&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Wed Nov 17 20:47:07 2010
@@ -616,7 +616,7 @@
// type than the actual system thread ID.
uint32_t
GetIndexID () const;
-
+
//------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
@@ -642,6 +642,10 @@
friend class ThreadPlan;
friend class StackFrameList;
+
+ // This is necessary to make sure thread assets get destroyed while the thread is still in good shape
+ // to call virtual thread methods. This must be called by classes that derive from Thread in their destructor.
+ virtual void DestroyThread ();
void
PushPlan (lldb::ThreadPlanSP &plan_sp);
@@ -688,6 +692,7 @@
int m_resume_signal; ///< The signal that should be used when continuing this thread.
lldb::StateType m_resume_state; ///< The state that indicates what this thread should do when the process is resumed.
std::auto_ptr<lldb_private::Unwind> m_unwinder_ap;
+ bool m_destroy_called; // This is used internally to make sure derived Thread classes call DestroyThread.
private:
//------------------------------------------------------------------
// For Thread only
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=119675&r1=119674&r2=119675&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 17 20:47:07 2010
@@ -2452,7 +2452,6 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=119675&r1=119674&r2=119675&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Nov 17 20:47:07 2010
@@ -590,7 +590,8 @@
break;
}
- if (try_all_threads)
+ if (try_all_threads
+ && (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent (event_sp.get())))
{
call_plan_ptr->SetStopOthers (false);
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp?rev=119675&r1=119674&r2=119675&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp Wed Nov 17 20:47:07 2010
@@ -55,6 +55,7 @@
ThreadMacOSX::~ThreadMacOSX ()
{
+ DestroyThread();
}
#if defined (__i386__) || defined (__x86_64__)
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=119675&r1=119674&r2=119675&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Wed Nov 17 20:47:07 2010
@@ -48,6 +48,7 @@
ThreadGDBRemote::~ThreadGDBRemote ()
{
ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::~ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+ DestroyThread();
}
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=119675&r1=119674&r2=119675&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Wed Nov 17 20:47:07 2010
@@ -54,7 +54,8 @@
m_curr_frames_ap (),
m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER),
m_resume_state (eStateRunning),
- m_unwinder_ap ()
+ m_unwinder_ap (),
+ m_destroy_called (false)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
@@ -71,6 +72,17 @@
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p Thread::~Thread(tid = 0x%4.4x)", this, GetID());
+ /// If you hit this assert, it means your derived class forgot to call DoDestroy in its destructor.
+ assert (m_destroy_called);
+}
+
+void
+Thread::DestroyThread ()
+{
+ m_plan_stack.clear();
+ m_discarded_plan_stack.clear();
+ m_completed_plan_stack.clear();
+ m_destroy_called = true;
}
int
@@ -625,7 +637,6 @@
}
}
- // FIXME: What should we do about the immediate plans?
}
ThreadPlan *
Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=119675&r1=119674&r2=119675&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanBase.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanBase.cpp Wed Nov 17 20:47:07 2010
@@ -36,7 +36,14 @@
ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes, eVoteNoOpinion)
{
// Set the tracer to a default tracer.
+ // FIXME: need to add a thread settings variable to pix various tracers...
+#define THREAD_PLAN_USE_ASSEMBLY_TRACER 1
+
+#ifdef THREAD_PLAN_USE_ASSEMBLY_TRACER
+ ThreadPlanTracerSP new_tracer_sp (new ThreadPlanAssemblyTracer (m_thread));
+#else
ThreadPlanTracerSP new_tracer_sp (new ThreadPlanTracer (m_thread));
+#endif
new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState());
SetThreadPlanTracer(new_tracer_sp);
}
More information about the lldb-commits
mailing list