[Lldb-commits] [lldb] r119757 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/Log.h include/lldb/Target/Process.h include/lldb/Target/Target.h include/lldb/Target/Thread.h lldb.xcodeproj/project.pbxproj source/Core/Debugger.cpp source/Core/Log.cpp source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp source/Target/Process.cpp source/Target/Target.cpp source/Target/Thread.cpp source/lldb-log.cpp source/lldb.cpp
Greg Clayton
gclayton at apple.com
Thu Nov 18 15:32:36 PST 2010
Author: gclayton
Date: Thu Nov 18 17:32:35 2010
New Revision: 119757
URL: http://llvm.org/viewvc/llvm-project?rev=119757&view=rev
Log:
Cleaned up code that wasn't using the Initialize and Terminate paradigm by
changing it to use it. There was an extra parameter added to the static
accessor global user settings controllers that wasn't needed. A bool was being
used as a parameter to the accessor just so it could be used to clean up
the global user settings controller which is now fixed by splitting up the
initialization into the "static void Class::Initialize()", access into the
"static UserSettingsControllerSP & Class::GetSettingsController()", and
cleanup into "static void Class::Terminate()".
Also added initialize and terminate calls to the logging code to avoid issues
when LLDB is shutting down. There were cases after the logging was switched
over to use shared pointers where we could crash if the global destructor
chain was being run and it causes the log to be destroyed and any any logging
occurred.
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/Log.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/Log.cpp
lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/lldb-log.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=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Nov 18 17:32:35 2010
@@ -247,7 +247,7 @@
};
static lldb::UserSettingsControllerSP &
- GetSettingsController (bool finish = false);
+ GetSettingsController ();
static lldb::DebuggerSP
CreateInstance ();
Modified: lldb/trunk/include/lldb/Core/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Log.h (original)
+++ lldb/trunk/include/lldb/Core/Log.h Thu Nov 18 17:32:35 2010
@@ -100,6 +100,12 @@
static void
ListAllLogChannels (Stream *strm);
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
//------------------------------------------------------------------
// Member functions
//------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Nov 18 17:32:35 2010
@@ -393,8 +393,14 @@
#endif
- static lldb::UserSettingsControllerSP
- GetSettingsController (bool finish = false);
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ static lldb::UserSettingsControllerSP &
+ GetSettingsController ();
void
UpdateInstanceName ();
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Nov 18 17:32:35 2010
@@ -123,8 +123,14 @@
DISALLOW_COPY_AND_ASSIGN (SettingsController);
};
- static lldb::UserSettingsControllerSP
- GetSettingsController (bool finish = false);
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ static lldb::UserSettingsControllerSP &
+ GetSettingsController ();
static ArchSpec
GetDefaultArchitecture ();
Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Thu Nov 18 17:32:35 2010
@@ -92,14 +92,14 @@
{
public:
- class ThreadSettingsController : public UserSettingsController
+ class SettingsController : public UserSettingsController
{
public:
- ThreadSettingsController ();
+ SettingsController ();
virtual
- ~ThreadSettingsController ();
+ ~SettingsController ();
static SettingEntry global_settings_table[];
static SettingEntry instance_settings_table[];
@@ -113,7 +113,7 @@
// Class-wide settings.
- DISALLOW_COPY_AND_ASSIGN (ThreadSettingsController);
+ DISALLOW_COPY_AND_ASSIGN (SettingsController);
};
class RegisterCheckpoint
@@ -168,8 +168,14 @@
void
UpdateInstanceName ();
- static lldb::UserSettingsControllerSP
- GetSettingsController (bool finish = false);
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ static lldb::UserSettingsControllerSP &
+ GetSettingsController ();
Thread (Process &process, lldb::tid_t tid);
virtual ~Thread();
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Nov 18 17:32:35 2010
@@ -2452,6 +2452,7 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Nov 18 17:32:35 2010
@@ -52,12 +52,27 @@
#pragma mark Debugger
+UserSettingsControllerSP &
+Debugger::GetSettingsController ()
+{
+ static UserSettingsControllerSP g_settings_controller;
+ return g_settings_controller;
+}
+
void
Debugger::Initialize ()
{
if (g_shared_debugger_refcount == 0)
+ {
lldb_private::Initialize();
+ UserSettingsControllerSP &usc = GetSettingsController();
+ usc.reset (new SettingsController);
+ UserSettingsController::InitializeSettingsController (usc,
+ SettingsController::global_settings_table,
+ SettingsController::instance_settings_table);
+ }
g_shared_debugger_refcount++;
+
}
void
@@ -68,10 +83,16 @@
g_shared_debugger_refcount--;
if (g_shared_debugger_refcount == 0)
{
+ UserSettingsControllerSP &usc = GetSettingsController();
+ UserSettingsController::FinalizeSettingsController (usc);
+ usc.reset();
lldb_private::WillTerminate();
lldb_private::Terminate();
}
}
+ // Clear our master list of debugger objects
+ Mutex::Locker locker (GetDebuggerListMutex ());
+ GetDebuggerList().clear();
}
DebuggerSP
@@ -144,7 +165,7 @@
Debugger::Debugger () :
UserID (g_unique_id++),
- DebuggerInstanceSettings (*(Debugger::GetSettingsController().get())),
+ DebuggerInstanceSettings (*Debugger::GetSettingsController()),
m_input_comm("debugger.input"),
m_input_file (),
m_output_file (),
@@ -536,29 +557,6 @@
return debugger_sp;
}
-lldb::UserSettingsControllerSP &
-Debugger::GetSettingsController (bool finish)
-{
- static lldb::UserSettingsControllerSP g_settings_controller (new SettingsController);
- static bool initialized = false;
-
- if (!initialized)
- {
- initialized = UserSettingsController::InitializeSettingsController (g_settings_controller,
- Debugger::SettingsController::global_settings_table,
- Debugger::SettingsController::instance_settings_table);
- }
-
- if (finish)
- {
- UserSettingsControllerSP parent = g_settings_controller->GetParent();
- if (parent)
- parent->RemoveChild (g_settings_controller);
- g_settings_controller.reset();
- }
- return g_settings_controller;
-}
-
static void
TestPromptFormats (StackFrame *frame)
{
@@ -1261,7 +1259,7 @@
lldb::InstanceSettingsSP
Debugger::SettingsController::CreateInstanceSettings (const char *instance_name)
{
- DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*(Debugger::GetSettingsController().get()),
+ DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*Debugger::GetSettingsController(),
false, instance_name);
lldb::InstanceSettingsSP new_settings_sp (new_settings);
return new_settings_sp;
@@ -1306,7 +1304,7 @@
}
DebuggerInstanceSettings::DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs) :
- InstanceSettings (*(Debugger::GetSettingsController().get()), CreateInstanceName ().AsCString()),
+ InstanceSettings (*Debugger::GetSettingsController(), CreateInstanceName ().AsCString()),
m_prompt (rhs.m_prompt),
m_frame_format (rhs.m_frame_format),
m_thread_format (rhs.m_thread_format),
Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Thu Nov 18 17:32:35 2010
@@ -389,7 +389,7 @@
{
CallbackMap &callback_map = GetCallbackMap ();
CallbackMapIter pos, end = callback_map.end();
- Args args ("all");
+ Args args;
for (pos = callback_map.begin(); pos != end; ++pos)
pos->second.disable (args, feedback_strm);
@@ -401,6 +401,19 @@
}
void
+Log::Initialize()
+{
+ Log::Callbacks log_callbacks = { DisableLog, EnableLog, ListLogCategories };
+ Log::RegisterLogChannel ("lldb", log_callbacks);
+}
+
+void
+Log::Terminate ()
+{
+ DisableAllLogChannels (NULL);
+}
+
+void
Log::ListAllLogChannels (Stream *strm)
{
CallbackMap &callback_map = GetCallbackMap ();
Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSXLog.cpp Thu Nov 18 17:32:35 2010
@@ -48,29 +48,33 @@
LogSP log (GetLog ());
if (log)
{
- uint32_t flag_bits = log->GetMask().Get();
+ uint32_t flag_bits = 0;
const size_t argc = args.GetArgumentCount ();
- for (size_t i = 0; i < argc; ++i)
+ if (argc > 0)
{
- const char *arg = args.GetArgumentAtIndex (i);
-
- if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~PD_LOG_ALL;
- else if (::strcasestr (arg, "break") == arg ) flag_bits &= ~PD_LOG_BREAKPOINTS;
- else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~PD_LOG_DEFAULT;
- else if (::strcasestr (arg, "exc") == arg ) flag_bits &= ~PD_LOG_EXCEPTIONS;
- else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~PD_LOG_MEMORY;
- else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~PD_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~PD_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp (arg, "protections")== 0 ) flag_bits &= ~PD_LOG_PROCESS;
- else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~PD_LOG_STEP;
- else if (::strcasecmp (arg, "task") == 0 ) flag_bits &= ~PD_LOG_TASK;
- else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~PD_LOG_THREAD;
- else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~PD_LOG_VERBOSE;
- else if (::strcasestr (arg, "watch") == arg ) flag_bits &= ~PD_LOG_WATCHPOINTS;
- else
+ flag_bits = log->GetMask().Get();
+ for (size_t i = 0; i < argc; ++i)
{
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories (feedback_strm);
+ const char *arg = args.GetArgumentAtIndex (i);
+
+ if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~PD_LOG_ALL;
+ else if (::strcasestr (arg, "break") == arg ) flag_bits &= ~PD_LOG_BREAKPOINTS;
+ else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~PD_LOG_DEFAULT;
+ else if (::strcasestr (arg, "exc") == arg ) flag_bits &= ~PD_LOG_EXCEPTIONS;
+ else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~PD_LOG_MEMORY;
+ else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~PD_LOG_MEMORY_DATA_SHORT;
+ else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~PD_LOG_MEMORY_DATA_LONG;
+ else if (::strcasecmp (arg, "protections")== 0 ) flag_bits &= ~PD_LOG_PROCESS;
+ else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~PD_LOG_STEP;
+ else if (::strcasecmp (arg, "task") == 0 ) flag_bits &= ~PD_LOG_TASK;
+ else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~PD_LOG_THREAD;
+ else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~PD_LOG_VERBOSE;
+ else if (::strcasestr (arg, "watch") == arg ) flag_bits &= ~PD_LOG_WATCHPOINTS;
+ else
+ {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ ListLogCategories (feedback_strm);
+ }
}
}
if (flag_bits == 0)
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp Thu Nov 18 17:32:35 2010
@@ -48,33 +48,38 @@
LogSP log (GetLog ());
if (log)
{
- uint32_t flag_bits = log->GetMask().Get();
+ uint32_t flag_bits = 0;
+
const size_t argc = args.GetArgumentCount ();
- for (size_t i = 0; i < argc; ++i)
+ if (argc > 0)
{
- const char *arg = args.GetArgumentAtIndex (i);
-
-
- if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~GDBR_LOG_ALL;
- else if (::strcasecmp (arg, "async") == 0 ) flag_bits &= ~GDBR_LOG_ASYNC;
- else if (::strcasestr (arg, "break") == arg ) flag_bits &= ~GDBR_LOG_BREAKPOINTS;
- else if (::strcasestr (arg, "comm") == arg ) flag_bits &= ~GDBR_LOG_COMM;
- else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~GDBR_LOG_DEFAULT;
- else if (::strcasecmp (arg, "packets") == 0 ) flag_bits &= ~GDBR_LOG_PACKETS;
- else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY;
- else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~GDBR_LOG_PROCESS;
- else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~GDBR_LOG_STEP;
- else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~GDBR_LOG_THREAD;
- else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~GDBR_LOG_VERBOSE;
- else if (::strcasestr (arg, "watch") == arg ) flag_bits &= ~GDBR_LOG_WATCHPOINTS;
- else
+ flag_bits = log->GetMask().Get();
+ for (size_t i = 0; i < argc; ++i)
{
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories (feedback_strm);
+ const char *arg = args.GetArgumentAtIndex (i);
+
+
+ if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~GDBR_LOG_ALL;
+ else if (::strcasecmp (arg, "async") == 0 ) flag_bits &= ~GDBR_LOG_ASYNC;
+ else if (::strcasestr (arg, "break") == arg ) flag_bits &= ~GDBR_LOG_BREAKPOINTS;
+ else if (::strcasestr (arg, "comm") == arg ) flag_bits &= ~GDBR_LOG_COMM;
+ else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~GDBR_LOG_DEFAULT;
+ else if (::strcasecmp (arg, "packets") == 0 ) flag_bits &= ~GDBR_LOG_PACKETS;
+ else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY;
+ else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_SHORT;
+ else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_LONG;
+ else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~GDBR_LOG_PROCESS;
+ else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~GDBR_LOG_STEP;
+ else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~GDBR_LOG_THREAD;
+ else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~GDBR_LOG_VERBOSE;
+ else if (::strcasestr (arg, "watch") == arg ) flag_bits &= ~GDBR_LOG_WATCHPOINTS;
+ else
+ {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ ListLogCategories (feedback_strm);
+ }
+
}
-
}
if (flag_bits == 0)
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Nov 18 17:32:35 2010
@@ -2237,26 +2237,29 @@
m_target.GetDebugger().PopInputReader (m_process_input_reader);
}
-lldb::UserSettingsControllerSP
-Process::GetSettingsController (bool finish)
-{
- static UserSettingsControllerSP g_settings_controller (new SettingsController);
- static bool initialized = false;
- if (!initialized)
- {
- initialized = UserSettingsController::InitializeSettingsController (g_settings_controller,
- Process::SettingsController::global_settings_table,
- Process::SettingsController::instance_settings_table);
- }
+void
+Process::Initialize ()
+{
+ UserSettingsControllerSP &usc = GetSettingsController();
+ usc.reset (new SettingsController);
+ UserSettingsController::InitializeSettingsController (usc,
+ SettingsController::global_settings_table,
+ SettingsController::instance_settings_table);
+}
- if (finish)
- {
- UserSettingsController::FinalizeSettingsController (g_settings_controller);
- g_settings_controller.reset();
- initialized = false;
- }
+void
+Process::Terminate ()
+{
+ UserSettingsControllerSP &usc = GetSettingsController();
+ UserSettingsController::FinalizeSettingsController (usc);
+ usc.reset();
+}
+UserSettingsControllerSP &
+Process::GetSettingsController ()
+{
+ static UserSettingsControllerSP g_settings_controller;
return g_settings_controller;
}
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Nov 18 17:32:35 2010
@@ -769,26 +769,28 @@
return m_scratch_ast_context_ap.get();
}
-lldb::UserSettingsControllerSP
-Target::GetSettingsController (bool finish)
+void
+Target::Initialize ()
{
- static lldb::UserSettingsControllerSP g_settings_controller (new SettingsController);
- static bool initialized = false;
-
- if (!initialized)
- {
- initialized = UserSettingsController::InitializeSettingsController (g_settings_controller,
- Target::SettingsController::global_settings_table,
- Target::SettingsController::instance_settings_table);
- }
+ UserSettingsControllerSP &usc = GetSettingsController();
+ usc.reset (new SettingsController);
+ UserSettingsController::InitializeSettingsController (usc,
+ SettingsController::global_settings_table,
+ SettingsController::instance_settings_table);
+}
- if (finish)
- {
- UserSettingsController::FinalizeSettingsController (g_settings_controller);
- g_settings_controller.reset();
- initialized = false;
- }
+void
+Target::Terminate ()
+{
+ UserSettingsControllerSP &usc = GetSettingsController();
+ UserSettingsController::FinalizeSettingsController (usc);
+ usc.reset();
+}
+UserSettingsControllerSP &
+Target::GetSettingsController ()
+{
+ static UserSettingsControllerSP g_settings_controller;
return g_settings_controller;
}
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Thu Nov 18 17:32:35 2010
@@ -930,26 +930,29 @@
return m_process.GetThreadList().GetThreadSPForThreadPtr(this);
}
-lldb::UserSettingsControllerSP
-Thread::GetSettingsController (bool finish)
-{
- static UserSettingsControllerSP g_settings_controller (new ThreadSettingsController);
- static bool initialized = false;
- if (!initialized)
- {
- initialized = UserSettingsController::InitializeSettingsController (g_settings_controller,
- Thread::ThreadSettingsController::global_settings_table,
- Thread::ThreadSettingsController::instance_settings_table);
- }
+void
+Thread::Initialize ()
+{
+ UserSettingsControllerSP &usc = GetSettingsController();
+ usc.reset (new SettingsController);
+ UserSettingsController::InitializeSettingsController (usc,
+ SettingsController::global_settings_table,
+ SettingsController::instance_settings_table);
+}
- if (finish)
- {
- UserSettingsController::FinalizeSettingsController (g_settings_controller);
- g_settings_controller.reset();
- initialized = false;
- }
+void
+Thread::Terminate ()
+{
+ UserSettingsControllerSP &usc = GetSettingsController();
+ UserSettingsController::FinalizeSettingsController (usc);
+ usc.reset();
+}
+UserSettingsControllerSP &
+Thread::GetSettingsController ()
+{
+ static UserSettingsControllerSP g_settings_controller;
return g_settings_controller;
}
@@ -1010,24 +1013,24 @@
return unknown_state_string;
}
-#pragma mark "Thread::ThreadSettingsController"
+#pragma mark "Thread::SettingsController"
//--------------------------------------------------------------
-// class Thread::ThreadSettingsController
+// class Thread::SettingsController
//--------------------------------------------------------------
-Thread::ThreadSettingsController::ThreadSettingsController () :
+Thread::SettingsController::SettingsController () :
UserSettingsController ("thread", Process::GetSettingsController())
{
m_default_settings.reset (new ThreadInstanceSettings (*this, false,
InstanceSettings::GetDefaultName().AsCString()));
}
-Thread::ThreadSettingsController::~ThreadSettingsController ()
+Thread::SettingsController::~SettingsController ()
{
}
lldb::InstanceSettingsSP
-Thread::ThreadSettingsController::CreateInstanceSettings (const char *instance_name)
+Thread::SettingsController::CreateInstanceSettings (const char *instance_name)
{
ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get()),
false, instance_name);
@@ -1218,11 +1221,11 @@
}
//--------------------------------------------------
-// ThreadSettingsController Variable Tables
+// SettingsController Variable Tables
//--------------------------------------------------
SettingEntry
-Thread::ThreadSettingsController::global_settings_table[] =
+Thread::SettingsController::global_settings_table[] =
{
//{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"},
{ NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
@@ -1230,7 +1233,7 @@
SettingEntry
-Thread::ThreadSettingsController::instance_settings_table[] =
+Thread::SettingsController::instance_settings_table[] =
{
//{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"},
{ "step-avoid-regexp", eSetVarTypeString, "", NULL, false, false, "A regular expression defining functions step-in won't stop in." },
Modified: lldb/trunk/source/lldb-log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/lldb-log.cpp (original)
+++ lldb/trunk/source/lldb-log.cpp Thu Nov 18 17:32:35 2010
@@ -101,43 +101,46 @@
lldb_private::DisableLog (Args &args, Stream *feedback_strm)
{
LogSP log(GetLog ());
- uint32_t flag_bits;
if (log)
{
- flag_bits = log->GetMask().Get();
+ uint32_t flag_bits = 0;
const size_t argc = args.GetArgumentCount ();
- for (size_t i = 0; i < argc; ++i)
+ if (argc > 0)
{
- const char *arg = args.GetArgumentAtIndex (i);
-
- if (strcasecmp(arg, "all") == 0 ) flag_bits &= ~LIBLLDB_LOG_ALL;
- else if (strcasecmp(arg, "api") == 0) flag_bits &= ~LIBLLDB_LOG_API;
- else if (strcasestr(arg, "break") == arg) flag_bits &= ~LIBLLDB_LOG_BREAKPOINTS;
- else if (strcasecmp(arg, "default") == 0 ) flag_bits &= ~LIBLLDB_LOG_DEFAULT;
- else if (strcasecmp(arg, "dyld") == 0 ) flag_bits &= ~LIBLLDB_LOG_DYNAMIC_LOADER;
- else if (strcasestr(arg, "event") == arg) flag_bits &= ~LIBLLDB_LOG_EVENTS;
- else if (strcasestr(arg, "expr") == arg) flag_bits &= ~LIBLLDB_LOG_EXPRESSIONS;
- else if (strcasestr(arg, "object") == arg) flag_bits &= ~LIBLLDB_LOG_OBJECT;
- else if (strcasecmp(arg, "process") == 0 ) flag_bits &= ~LIBLLDB_LOG_PROCESS;
- else if (strcasecmp(arg, "script") == 0) flag_bits &= ~LIBLLDB_LOG_SCRIPT;
- else if (strcasecmp(arg, "state") == 0 ) flag_bits &= ~LIBLLDB_LOG_STATE;
- else if (strcasecmp(arg, "step") == 0 ) flag_bits &= ~LIBLLDB_LOG_STEP;
- else if (strcasecmp(arg, "thread") == 0 ) flag_bits &= ~LIBLLDB_LOG_THREAD;
- else if (strcasecmp(arg, "verbose") == 0 ) flag_bits &= ~LIBLLDB_LOG_VERBOSE;
- else if (strcasestr(arg, "watch") == arg) flag_bits &= ~LIBLLDB_LOG_WATCHPOINTS;
- else if (strcasestr(arg, "temp") == arg) flag_bits &= ~LIBLLDB_LOG_TEMPORARY;
- else if (strcasestr(arg, "comm") == arg) flag_bits &= ~LIBLLDB_LOG_COMMUNICATION;
- else if (strcasestr(arg, "conn") == arg) flag_bits &= ~LIBLLDB_LOG_CONNECTION;
- else if (strcasestr(arg, "host") == arg) flag_bits &= ~LIBLLDB_LOG_HOST;
- else if (strcasestr(arg, "unwind") == arg) flag_bits &= ~LIBLLDB_LOG_UNWIND;
- else
+ flag_bits = log->GetMask().Get();
+ for (size_t i = 0; i < argc; ++i)
{
- feedback_strm->Printf ("error: unrecognized log category '%s'\n", arg);
- ListLogCategories (feedback_strm);
- return;
+ const char *arg = args.GetArgumentAtIndex (i);
+
+ if (strcasecmp(arg, "all") == 0 ) flag_bits &= ~LIBLLDB_LOG_ALL;
+ else if (strcasecmp(arg, "api") == 0) flag_bits &= ~LIBLLDB_LOG_API;
+ else if (strcasestr(arg, "break") == arg) flag_bits &= ~LIBLLDB_LOG_BREAKPOINTS;
+ else if (strcasecmp(arg, "default") == 0 ) flag_bits &= ~LIBLLDB_LOG_DEFAULT;
+ else if (strcasecmp(arg, "dyld") == 0 ) flag_bits &= ~LIBLLDB_LOG_DYNAMIC_LOADER;
+ else if (strcasestr(arg, "event") == arg) flag_bits &= ~LIBLLDB_LOG_EVENTS;
+ else if (strcasestr(arg, "expr") == arg) flag_bits &= ~LIBLLDB_LOG_EXPRESSIONS;
+ else if (strcasestr(arg, "object") == arg) flag_bits &= ~LIBLLDB_LOG_OBJECT;
+ else if (strcasecmp(arg, "process") == 0 ) flag_bits &= ~LIBLLDB_LOG_PROCESS;
+ else if (strcasecmp(arg, "script") == 0) flag_bits &= ~LIBLLDB_LOG_SCRIPT;
+ else if (strcasecmp(arg, "state") == 0 ) flag_bits &= ~LIBLLDB_LOG_STATE;
+ else if (strcasecmp(arg, "step") == 0 ) flag_bits &= ~LIBLLDB_LOG_STEP;
+ else if (strcasecmp(arg, "thread") == 0 ) flag_bits &= ~LIBLLDB_LOG_THREAD;
+ else if (strcasecmp(arg, "verbose") == 0 ) flag_bits &= ~LIBLLDB_LOG_VERBOSE;
+ else if (strcasestr(arg, "watch") == arg) flag_bits &= ~LIBLLDB_LOG_WATCHPOINTS;
+ else if (strcasestr(arg, "temp") == arg) flag_bits &= ~LIBLLDB_LOG_TEMPORARY;
+ else if (strcasestr(arg, "comm") == arg) flag_bits &= ~LIBLLDB_LOG_COMMUNICATION;
+ else if (strcasestr(arg, "conn") == arg) flag_bits &= ~LIBLLDB_LOG_CONNECTION;
+ else if (strcasestr(arg, "host") == arg) flag_bits &= ~LIBLLDB_LOG_HOST;
+ else if (strcasestr(arg, "unwind") == arg) flag_bits &= ~LIBLLDB_LOG_UNWIND;
+ else
+ {
+ feedback_strm->Printf ("error: unrecognized log category '%s'\n", arg);
+ ListLogCategories (feedback_strm);
+ return;
+ }
+
}
-
}
if (flag_bits == 0)
GetLog ().reset();
Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=119757&r1=119756&r2=119757&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Thu Nov 18 17:32:35 2010
@@ -57,12 +57,13 @@
if (!g_inited)
{
g_inited = true;
+ Log::Initialize();
Timer::Initialize ();
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
- Log::Callbacks log_callbacks = { DisableLog, EnableLog, ListLogCategories };
-
- Log::RegisterLogChannel ("lldb", log_callbacks);
+
+ Target::Initialize ();
+ Process::Initialize ();
+ Thread::Initialize ();
DisassemblerLLVM::Initialize();
ObjectContainerBSDArchive::Initialize();
ObjectFileELF::Initialize();
@@ -86,10 +87,6 @@
//ProcessMacOSX::Initialize();
SymbolVendorMacOSX::Initialize();
#endif
- Debugger::GetSettingsController (false);
- Target::GetSettingsController (false);
- Process::GetSettingsController (false);
- Thread::GetSettingsController (false);
#ifdef __linux__
ProcessLinux::Initialize();
#endif
@@ -128,14 +125,15 @@
SymbolVendorMacOSX::Terminate();
#endif
- Thread::GetSettingsController (true);
- Process::GetSettingsController (true);
- Target::GetSettingsController (true);
- Debugger::GetSettingsController (true);
-
+ Thread::Terminate ();
+ Process::Terminate ();
+ Target::Terminate ();
+
#ifdef __linux__
ProcessLinux::Terminate();
#endif
+
+ Log::Terminate();
}
extern "C" const double LLDBVersionNumber;
More information about the lldb-commits
mailing list