[Lldb-commits] [lldb] r127430 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Target/Process.h include/lldb/Target/Target.h include/lldb/Target/Thread.h source/Core/Debugger.cpp source/Target/Process.cpp source/Target/Target.cpp source/Target/Thread.cpp source/lldb.cpp
Caroline Tice
ctice at apple.com
Thu Mar 10 14:14:10 PST 2011
Author: ctice
Date: Thu Mar 10 16:14:10 2011
New Revision: 127430
URL: http://llvm.org/viewvc/llvm-project?rev=127430&view=rev
Log:
The UserSettings controllers must be initialized & terminated in the
correct order. Previously this was tacitly implemented but not
enforced, so it was possible to accidentally do things in the wrong
order and cause problems. This fixes that problem.
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/lldb.cpp
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Mar 10 16:14:10 2011
@@ -261,6 +261,12 @@
Terminate ();
static void
+ SettingsInitialize ();
+
+ static void
+ SettingsTerminate ();
+
+ static void
Destroy (lldb::DebuggerSP &debugger_sp);
~Debugger ();
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Mar 10 16:14:10 2011
@@ -539,13 +539,10 @@
#endif
static void
- Initialize ();
+ SettingsInitialize ();
static void
- DidInitialize ();
-
- static void
- Terminate ();
+ SettingsTerminate ();
static lldb::UserSettingsControllerSP &
GetSettingsController ();
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Mar 10 16:14:10 2011
@@ -141,10 +141,10 @@
};
static void
- Initialize ();
+ SettingsInitialize ();
static void
- Terminate ();
+ SettingsTerminate ();
static lldb::UserSettingsControllerSP &
GetSettingsController ();
Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Thu Mar 10 16:14:10 2011
@@ -194,10 +194,10 @@
UpdateInstanceName ();
static void
- Initialize ();
+ SettingsInitialize ();
static void
- Terminate ();
+ SettingsTerminate ();
static lldb::UserSettingsControllerSP &
GetSettingsController ();
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Mar 10 16:14:10 2011
@@ -71,11 +71,6 @@
{
if (g_shared_debugger_refcount == 0)
{
- UserSettingsControllerSP &usc = GetSettingsController();
- usc.reset (new SettingsController);
- UserSettingsController::InitializeSettingsController (usc,
- SettingsController::global_settings_table,
- SettingsController::instance_settings_table);
lldb_private::Initialize();
}
g_shared_debugger_refcount++;
@@ -92,9 +87,6 @@
{
lldb_private::WillTerminate();
lldb_private::Terminate();
- UserSettingsControllerSP &usc = GetSettingsController();
- UserSettingsController::FinalizeSettingsController (usc);
- usc.reset();
// Clear our master list of debugger objects
Mutex::Locker locker (GetDebuggerListMutex ());
@@ -103,6 +95,40 @@
}
}
+void
+Debugger::SettingsInitialize ()
+{
+ static bool g_initialized = false;
+
+ if (!g_initialized)
+ {
+ g_initialized = true;
+ UserSettingsControllerSP &usc = GetSettingsController();
+ usc.reset (new SettingsController);
+ UserSettingsController::InitializeSettingsController (usc,
+ SettingsController::global_settings_table,
+ SettingsController::instance_settings_table);
+ // Now call SettingsInitialize for each settings 'child' of Debugger
+ Target::SettingsInitialize ();
+ }
+}
+
+void
+Debugger::SettingsTerminate ()
+{
+
+ // Must call SettingsTerminate() for each settings 'child' of Debugger, before terminating the Debugger's
+ // Settings.
+
+ Target::SettingsTerminate ();
+
+ // Now terminate the Debugger Settings.
+
+ UserSettingsControllerSP &usc = GetSettingsController();
+ UserSettingsController::FinalizeSettingsController (usc);
+ usc.reset();
+}
+
DebuggerSP
Debugger::CreateInstance ()
{
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Mar 10 16:14:10 2011
@@ -2671,7 +2671,7 @@
// The process needs to know about installed plug-ins
void
-Process::DidInitialize ()
+Process::SettingsInitialize ()
{
static std::vector<lldb::OptionEnumValueElement> g_plugins;
@@ -2707,16 +2707,20 @@
UserSettingsController::InitializeSettingsController (usc,
SettingsController::global_settings_table,
SettingsController::instance_settings_table);
+
+ // Now call SettingsInitialize() for each 'child' of Process settings
+ Thread::SettingsInitialize ();
}
void
-Process::Initialize ()
-{
-}
-
-void
-Process::Terminate ()
+Process::SettingsTerminate ()
{
+ // Must call SettingsTerminate() on each 'child' of Process settings before terminating Process settings.
+
+ Thread::SettingsTerminate ();
+
+ // Now terminate Process Settings.
+
UserSettingsControllerSP &usc = GetSettingsController();
UserSettingsController::FinalizeSettingsController (usc);
usc.reset();
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Mar 10 16:14:10 2011
@@ -779,18 +779,28 @@
}
void
-Target::Initialize ()
+Target::SettingsInitialize ()
{
UserSettingsControllerSP &usc = GetSettingsController();
usc.reset (new SettingsController);
UserSettingsController::InitializeSettingsController (usc,
SettingsController::global_settings_table,
SettingsController::instance_settings_table);
+
+ // Now call SettingsInitialize() on each 'child' setting of Target
+ Process::SettingsInitialize ();
}
void
-Target::Terminate ()
+Target::SettingsTerminate ()
{
+
+ // Must call SettingsTerminate() on each settings 'child' of Target, before terminating Target's Settings.
+
+ Process::SettingsTerminate ();
+
+ // Now terminate Target Settings.
+
UserSettingsControllerSP &usc = GetSettingsController();
UserSettingsController::FinalizeSettingsController (usc);
usc.reset();
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Thu Mar 10 16:14:10 2011
@@ -1006,18 +1006,26 @@
void
-Thread::Initialize ()
+Thread::SettingsInitialize ()
{
UserSettingsControllerSP &usc = GetSettingsController();
usc.reset (new SettingsController);
UserSettingsController::InitializeSettingsController (usc,
SettingsController::global_settings_table,
SettingsController::instance_settings_table);
+
+ // Now call SettingsInitialize() on each 'child' setting of Thread.
+ // Currently there are none.
}
void
-Thread::Terminate ()
+Thread::SettingsTerminate ()
{
+ // Must call SettingsTerminate() on each 'child' setting of Thread before terminating Thread settings.
+ // Currently there are none.
+
+ // Now terminate Thread Settings.
+
UserSettingsControllerSP &usc = GetSettingsController();
UserSettingsController::FinalizeSettingsController (usc);
usc.reset();
Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=127430&r1=127429&r2=127430&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Thu Mar 10 16:14:10 2011
@@ -74,9 +74,6 @@
Timer::Initialize ();
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- Target::Initialize ();
- Process::Initialize ();
- Thread::Initialize ();
DisassemblerLLVM::Initialize();
ObjectContainerBSDArchive::Initialize();
ObjectFileELF::Initialize();
@@ -112,9 +109,10 @@
// Scan for any system or user LLDB plug-ins
PluginManager::Initialize();
- // The process needs to know about installed plug-ins
- Process::DidInitialize ();
-
+ // The process settings need to know about installed plug-ins, so the Settings must be initialized
+ // AFTER PluginManager::Initialize is called.
+
+ Debugger::SettingsInitialize();
}
}
@@ -157,9 +155,7 @@
PlatformMacOSX::Terminate();
#endif
- Thread::Terminate ();
- Process::Terminate ();
- Target::Terminate ();
+ Debugger::SettingsTerminate ();
#if defined (__linux__)
PlatformLinux::Terminate();
More information about the lldb-commits
mailing list