[Lldb-commits] [lldb] r233758 - Rework LLDB system initialization.
Zachary Turner
zturner at google.com
Tue Mar 31 14:03:22 PDT 2015
Author: zturner
Date: Tue Mar 31 16:03:22 2015
New Revision: 233758
URL: http://llvm.org/viewvc/llvm-project?rev=233758&view=rev
Log:
Rework LLDB system initialization.
In an effort to reduce binary size for components not wishing to
link against all of LLDB, as well as a parallel effort to reduce
link dependencies on Python, this patch splits out the notion of
LLDB initialization into "full" and "common" initialization.
All code related to initializing the full LLDB suite lives directly
in API now. Previously it was only referenced from API, but because
it was defined in lldbCore, it would get implicitly linked against
by everything including lldb-server, causing a considerable
increase in binary size.
By moving this to the API layer, it also creates a better layering
for the ongoing effort to make the embedded interpreter replacable
with one from a different language (or even be completely removeable).
One semantic change necessary to get this all working was to remove
the notion of a shared debugger refcount. The debugger is either
initialized or uninitialized now, and calling Initialize() multiple
times will simply have no effect, while the first Terminate() will
now shut it down no matter how many times Initialize() was called.
This behaves nicely with all of our supported usage patterns though,
and allows us to fix a number of nasty hacks from before.
Differential Revision: http://reviews.llvm.org/D8462
Added:
lldb/trunk/include/lldb/API/SystemInitializerFull.h
lldb/trunk/include/lldb/Initialization/SystemInitializer.h
lldb/trunk/include/lldb/Initialization/SystemInitializerCommon.h
lldb/trunk/include/lldb/Initialization/SystemLifetimeManager.h
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Initialization/SystemInitializer.cpp
lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
lldb/trunk/source/Initialization/SystemLifetimeManager.cpp
Removed:
lldb/trunk/include/lldb/Initialization/InitializeLLDB.h
lldb/trunk/source/Initialization/InitializeLLDB.cpp
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Initialization/CMakeLists.txt
lldb/trunk/source/Interpreter/ScriptInterpreter.cpp
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
lldb/trunk/tools/lldb-server/lldb-server.cpp
Added: lldb/trunk/include/lldb/API/SystemInitializerFull.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SystemInitializerFull.h?rev=233758&view=auto
==============================================================================
--- lldb/trunk/include/lldb/API/SystemInitializerFull.h (added)
+++ lldb/trunk/include/lldb/API/SystemInitializerFull.h Tue Mar 31 16:03:22 2015
@@ -0,0 +1,40 @@
+//===-- SystemInitializerFull.h ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SYSTEM_INITIALIZER_FULL_H
+#define LLDB_API_SYSTEM_INITIALIZER_FULL_H
+
+#include "lldb/Initialization/SystemInitializerCommon.h"
+
+namespace lldb_private
+{
+//------------------------------------------------------------------
+/// Initializes lldb.
+///
+/// This class is responsible for initializing all of lldb system
+/// services needed to use the full LLDB application. This class is
+/// not intended to be used externally, but is instead used
+/// internally by SBDebugger to initialize the system.
+//------------------------------------------------------------------
+class SystemInitializerFull : public SystemInitializerCommon
+{
+ public:
+ SystemInitializerFull();
+ virtual ~SystemInitializerFull();
+
+ void Initialize() override;
+ void Terminate() override;
+
+ private:
+ void InitializeSWIG();
+ void TerminateSWIG();
+};
+}
+
+#endif
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Tue Mar 31 16:03:22 2015
@@ -65,10 +65,10 @@ public:
FindTargetWithProcess (Process *process);
static void
- Initialize (LoadPluginCallbackType load_plugin_callback);
+ Initialize(LoadPluginCallbackType load_plugin_callback);
- static int
- Terminate ();
+ static void
+ Terminate();
static void
SettingsInitialize ();
@@ -248,9 +248,6 @@ public:
void
ClearIOHandlers ();
- static int
- TestDebuggerRefCount ();
-
bool
GetCloseInputOnEOF () const;
Removed: lldb/trunk/include/lldb/Initialization/InitializeLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Initialization/InitializeLLDB.h?rev=233757&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Initialization/InitializeLLDB.h (original)
+++ lldb/trunk/include/lldb/Initialization/InitializeLLDB.h (removed)
@@ -1,61 +0,0 @@
-//===-- InitializeLLDB.h ----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_INITIALIZATION_INITIALIZE_LLDB_H
-#define LLDB_INITIALIZATION_INITIALIZE_LLDB_H
-
-#include "lldb/lldb-private-types.h"
-
-namespace lldb_private
-{
-
-//------------------------------------------------------------------
-/// Initializes lldb.
-///
-/// This function should be called prior to using any lldb
-/// classes to ensure they have a chance to do any static
-/// initialization that they need to do.
-//------------------------------------------------------------------
-void Initialize(LoadPluginCallbackType load_plugin_callback);
-
-//------------------------------------------------------------------
-/// Initializes subset of lldb for LLGS.
-///
-/// This function only initializes the set of components and plugins
-/// necessary for lldb-platform and lldb-gdbserver, reducing the
-/// impact on the statically linked binary size.
-//------------------------------------------------------------------
-void InitializeForLLGS(LoadPluginCallbackType load_plugin_callback);
-
-//------------------------------------------------------------------
-/// Terminates lldb
-///
-/// This function optionally can be called when clients are done
-/// using lldb functionality to free up any static resources
-/// that have been allocated during initialization or during
-/// function calls. No lldb functions should be called after
-/// calling this function without again calling DCInitialize()
-/// again.
-//------------------------------------------------------------------
-void Terminate();
-
-//------------------------------------------------------------------
-/// Terminates subset of lldb initialized by InitializeForLLGS
-///
-/// This function optionally can be called when clients are done
-/// using lldb functionality to free up any static resources
-/// that have been allocated during initialization or during
-/// function calls. No lldb functions should be called after
-/// calling this function without again calling DCInitialize()
-/// again.
-//------------------------------------------------------------------
-void TerminateLLGS();
-}
-
-#endif
Added: lldb/trunk/include/lldb/Initialization/SystemInitializer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Initialization/SystemInitializer.h?rev=233758&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Initialization/SystemInitializer.h (added)
+++ lldb/trunk/include/lldb/Initialization/SystemInitializer.h Tue Mar 31 16:03:22 2015
@@ -0,0 +1,26 @@
+//===-- SystemInitializer.h -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H
+#define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H
+
+namespace lldb_private
+{
+class SystemInitializer
+{
+ public:
+ SystemInitializer();
+ virtual ~SystemInitializer();
+
+ virtual void Initialize() = 0;
+ virtual void Terminate() = 0;
+};
+}
+
+#endif
Added: lldb/trunk/include/lldb/Initialization/SystemInitializerCommon.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Initialization/SystemInitializerCommon.h?rev=233758&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Initialization/SystemInitializerCommon.h (added)
+++ lldb/trunk/include/lldb/Initialization/SystemInitializerCommon.h Tue Mar 31 16:03:22 2015
@@ -0,0 +1,38 @@
+//===-- SystemInitializerCommon.h -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H
+#define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H
+
+#include "SystemInitializer.h"
+
+namespace lldb_private
+{
+//------------------------------------------------------------------
+/// Initializes common lldb functionality.
+///
+/// This class is responsible for initializing a subset of lldb
+/// useful to both debug servers and debug clients. Debug servers
+/// do not use all of LLDB and desire small binary sizes, so this
+/// functionality is separate. This class is used by constructing
+/// an instance of SystemLifetimeManager with this class passed to
+/// the constructor.
+//------------------------------------------------------------------
+class SystemInitializerCommon : public SystemInitializer
+{
+ public:
+ SystemInitializerCommon();
+ virtual ~SystemInitializerCommon();
+
+ void Initialize() override;
+ void Terminate() override;
+};
+}
+
+#endif
Added: lldb/trunk/include/lldb/Initialization/SystemLifetimeManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Initialization/SystemLifetimeManager.h?rev=233758&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Initialization/SystemLifetimeManager.h (added)
+++ lldb/trunk/include/lldb/Initialization/SystemLifetimeManager.h Tue Mar 31 16:03:22 2015
@@ -0,0 +1,42 @@
+//===-- SystemLifetimeManager.h -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H
+#define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H
+
+#include "lldb/lldb-private-types.h"
+#include "lldb/Host/Mutex.h"
+
+#include <memory>
+
+namespace lldb_private
+{
+class SystemInitializer;
+
+class SystemLifetimeManager
+{
+ public:
+ SystemLifetimeManager();
+ ~SystemLifetimeManager();
+
+ void Initialize(std::unique_ptr<SystemInitializer> initializer, LoadPluginCallbackType plugin_callback);
+ void Terminate();
+
+ private:
+ Mutex m_mutex;
+ std::unique_ptr<SystemInitializer> m_initializer;
+ bool m_initialized;
+
+ // Noncopyable.
+ SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
+ SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = delete;
+};
+}
+
+#endif
Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Mar 31 16:03:22 2015
@@ -41,98 +41,6 @@ class ScriptInterpreter
{
public:
- typedef void (*SWIGInitCallback) (void);
-
- typedef bool (*SWIGBreakpointCallbackFunction) (const char *python_function_name,
- const char *session_dictionary_name,
- const lldb::StackFrameSP& frame_sp,
- const lldb::BreakpointLocationSP &bp_loc_sp);
-
- typedef bool (*SWIGWatchpointCallbackFunction) (const char *python_function_name,
- const char *session_dictionary_name,
- const lldb::StackFrameSP& frame_sp,
- const lldb::WatchpointSP &wp_sp);
-
- typedef bool (*SWIGPythonTypeScriptCallbackFunction) (const char *python_function_name,
- void *session_dictionary,
- const lldb::ValueObjectSP& valobj_sp,
- void** pyfunct_wrapper,
- const lldb::TypeSummaryOptionsSP& options,
- std::string& retval);
-
- typedef void* (*SWIGPythonCreateSyntheticProvider) (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ValueObjectSP& valobj_sp);
-
- typedef void* (*SWIGPythonCreateCommandObject) (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::DebuggerSP debugger_sp);
-
- typedef void* (*SWIGPythonCreateScriptedThreadPlan) (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ThreadPlanSP& thread_plan_sp);
-
- typedef bool (*SWIGPythonCallThreadPlan) (void *implementor, const char *method_name, Event *event_sp, bool &got_error);
-
- typedef void* (*SWIGPythonCreateOSPlugin) (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ProcessSP& process_sp);
-
- typedef size_t (*SWIGPythonCalculateNumChildren) (void *implementor);
- typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx);
- typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name);
- typedef void* (*SWIGPythonCastPyObjectToSBValue) (void* data);
- typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue) (void* data);
- typedef bool (*SWIGPythonUpdateSynthProviderInstance) (void* data);
- typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance) (void* data);
- typedef void* (*SWIGPythonGetValueSynthProviderInstance) (void *implementor);
-
- typedef bool (*SWIGPythonCallCommand) (const char *python_function_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP& debugger,
- const char* args,
- lldb_private::CommandReturnObject& cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
- typedef bool (*SWIGPythonCallCommandObject) (void *implementor,
- lldb::DebuggerSP& debugger,
- const char* args,
- lldb_private::CommandReturnObject& cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
-
- typedef bool (*SWIGPythonCallModuleInit) (const char *python_module_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP& debugger);
-
- typedef bool (*SWIGPythonScriptKeyword_Process) (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ProcessSP& process,
- std::string& output);
- typedef bool (*SWIGPythonScriptKeyword_Thread) (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ThreadSP& thread,
- std::string& output);
-
- typedef bool (*SWIGPythonScriptKeyword_Target) (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::TargetSP& target,
- std::string& output);
-
- typedef bool (*SWIGPythonScriptKeyword_Frame) (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::StackFrameSP& frame,
- std::string& output);
-
- typedef bool (*SWIGPythonScriptKeyword_Value) (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ValueObjectSP& value,
- std::string& output);
-
- typedef void* (*SWIGPython_GetDynamicSetting) (void* module,
- const char* setting,
- const lldb::TargetSP& target_sp);
-
typedef enum
{
eScriptReturnTypeCharPtr,
@@ -605,34 +513,6 @@ public:
static std::string
LanguageToString (lldb::ScriptLanguage language);
-
- static void
- InitializeInterpreter (SWIGInitCallback python_swig_init_callback,
- SWIGBreakpointCallbackFunction swig_breakpoint_callback,
- SWIGWatchpointCallbackFunction swig_watchpoint_callback,
- SWIGPythonTypeScriptCallbackFunction swig_typescript_callback,
- SWIGPythonCreateSyntheticProvider swig_synthetic_script,
- SWIGPythonCreateCommandObject swig_create_cmd,
- SWIGPythonCalculateNumChildren swig_calc_children,
- SWIGPythonGetChildAtIndex swig_get_child_index,
- SWIGPythonGetIndexOfChildWithName swig_get_index_child,
- SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue ,
- SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue,
- SWIGPythonUpdateSynthProviderInstance swig_update_provider,
- SWIGPythonMightHaveChildrenSynthProviderInstance swig_mighthavechildren_provider,
- SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider,
- SWIGPythonCallCommand swig_call_command,
- SWIGPythonCallCommandObject swig_call_command_object,
- SWIGPythonCallModuleInit swig_call_module_init,
- SWIGPythonCreateOSPlugin swig_create_os_plugin,
- SWIGPythonScriptKeyword_Process swig_run_script_keyword_process,
- SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread,
- SWIGPythonScriptKeyword_Target swig_run_script_keyword_target,
- SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame,
- SWIGPythonScriptKeyword_Value swig_run_script_keyword_value,
- SWIGPython_GetDynamicSetting swig_plugin_get,
- SWIGPythonCreateScriptedThreadPlan swig_thread_plan_script,
- SWIGPythonCallThreadPlan swig_call_thread_plan);
virtual void
ResetOutputFileHandle (FILE *new_fh) { } //By default, do nothing.
Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Tue Mar 31 16:03:22 2015
@@ -33,6 +33,97 @@ class ScriptInterpreterPython :
public IOHandlerDelegateMultiline
{
public:
+ typedef void (*SWIGInitCallback) (void);
+
+ typedef bool (*SWIGBreakpointCallbackFunction) (const char *python_function_name,
+ const char *session_dictionary_name,
+ const lldb::StackFrameSP& frame_sp,
+ const lldb::BreakpointLocationSP &bp_loc_sp);
+
+ typedef bool (*SWIGWatchpointCallbackFunction) (const char *python_function_name,
+ const char *session_dictionary_name,
+ const lldb::StackFrameSP& frame_sp,
+ const lldb::WatchpointSP &wp_sp);
+
+ typedef bool (*SWIGPythonTypeScriptCallbackFunction) (const char *python_function_name,
+ void *session_dictionary,
+ const lldb::ValueObjectSP& valobj_sp,
+ void** pyfunct_wrapper,
+ const lldb::TypeSummaryOptionsSP& options,
+ std::string& retval);
+
+ typedef void* (*SWIGPythonCreateSyntheticProvider) (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ValueObjectSP& valobj_sp);
+
+ typedef void* (*SWIGPythonCreateCommandObject) (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::DebuggerSP debugger_sp);
+
+ typedef void* (*SWIGPythonCreateScriptedThreadPlan) (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ThreadPlanSP& thread_plan_sp);
+
+ typedef bool (*SWIGPythonCallThreadPlan) (void *implementor, const char *method_name, Event *event_sp, bool &got_error);
+
+ typedef void* (*SWIGPythonCreateOSPlugin) (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ProcessSP& process_sp);
+
+ typedef size_t (*SWIGPythonCalculateNumChildren) (void *implementor);
+ typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx);
+ typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name);
+ typedef void* (*SWIGPythonCastPyObjectToSBValue) (void* data);
+ typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue) (void* data);
+ typedef bool (*SWIGPythonUpdateSynthProviderInstance) (void* data);
+ typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance) (void* data);
+ typedef void* (*SWIGPythonGetValueSynthProviderInstance) (void *implementor);
+
+ typedef bool (*SWIGPythonCallCommand) (const char *python_function_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP& debugger,
+ const char* args,
+ lldb_private::CommandReturnObject& cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+ typedef bool (*SWIGPythonCallCommandObject) (void *implementor,
+ lldb::DebuggerSP& debugger,
+ const char* args,
+ lldb_private::CommandReturnObject& cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+
+ typedef bool (*SWIGPythonCallModuleInit) (const char *python_module_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP& debugger);
+
+ typedef bool (*SWIGPythonScriptKeyword_Process) (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::ProcessSP& process,
+ std::string& output);
+ typedef bool (*SWIGPythonScriptKeyword_Thread) (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::ThreadSP& thread,
+ std::string& output);
+
+ typedef bool (*SWIGPythonScriptKeyword_Target) (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::TargetSP& target,
+ std::string& output);
+
+ typedef bool (*SWIGPythonScriptKeyword_Frame) (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::StackFrameSP& frame,
+ std::string& output);
+
+ typedef bool (*SWIGPythonScriptKeyword_Value) (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::ValueObjectSP& value,
+ std::string& output);
+
+ typedef void* (*SWIGPython_GetDynamicSetting) (void* module,
+ const char* setting,
+ const lldb::TargetSP& target_sp);
friend class IOHandlerPythonInterpreter;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Mar 31 16:03:22 2015
@@ -686,7 +686,10 @@
3F8160A61AB9F7DD001DA9DF /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8160A51AB9F7DD001DA9DF /* Logging.cpp */; };
3F8169191ABA2419001DA9DF /* ConvertEnum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169171ABA2419001DA9DF /* ConvertEnum.cpp */; };
3F81691A1ABA2419001DA9DF /* NameMatches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169181ABA2419001DA9DF /* NameMatches.cpp */; };
- 3F8169281ABB73D9001DA9DF /* InitializeLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */; };
+ 3F81692C1ABB7A1E001DA9DF /* SystemInitializerFull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F81692A1ABB7A16001DA9DF /* SystemInitializerFull.cpp */; };
+ 3F8169311ABB7A6D001DA9DF /* SystemInitializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F81692E1ABB7A6D001DA9DF /* SystemInitializer.cpp */; };
+ 3F8169321ABB7A6D001DA9DF /* SystemInitializerCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F81692F1ABB7A6D001DA9DF /* SystemInitializerCommon.cpp */; };
+ 3F8169331ABB7A6D001DA9DF /* SystemLifetimeManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169301ABB7A6D001DA9DF /* SystemLifetimeManager.cpp */; };
3FDFDDBD199C3A06009756A7 /* FileAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */; };
3FDFDDBF199D345E009756A7 /* FileCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBE199D345E009756A7 /* FileCache.cpp */; };
3FDFDDC6199D37ED009756A7 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDC5199D37ED009756A7 /* FileSystem.cpp */; };
@@ -2167,8 +2170,14 @@
3F8169181ABA2419001DA9DF /* NameMatches.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NameMatches.cpp; path = source/Utility/NameMatches.cpp; sourceTree = "<group>"; };
3F81691B1ABA242B001DA9DF /* ConvertEnum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ConvertEnum.h; path = include/lldb/Utility/ConvertEnum.h; sourceTree = "<group>"; };
3F81691C1ABA242B001DA9DF /* NameMatches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NameMatches.h; path = include/lldb/Utility/NameMatches.h; sourceTree = "<group>"; };
- 3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InitializeLLDB.cpp; path = source/Initialization/InitializeLLDB.cpp; sourceTree = "<group>"; };
- 3F8169291ABB73E6001DA9DF /* InitializeLLDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InitializeLLDB.h; path = include/lldb/Initialization/InitializeLLDB.h; sourceTree = "<group>"; };
+ 3F81692A1ABB7A16001DA9DF /* SystemInitializerFull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemInitializerFull.cpp; path = source/API/SystemInitializerFull.cpp; sourceTree = "<group>"; };
+ 3F81692D1ABB7A40001DA9DF /* SystemInitializerFull.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemInitializerFull.h; path = include/lldb/API/SystemInitializerFull.h; sourceTree = "<group>"; };
+ 3F81692E1ABB7A6D001DA9DF /* SystemInitializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemInitializer.cpp; path = source/Initialization/SystemInitializer.cpp; sourceTree = "<group>"; };
+ 3F81692F1ABB7A6D001DA9DF /* SystemInitializerCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemInitializerCommon.cpp; path = source/Initialization/SystemInitializerCommon.cpp; sourceTree = "<group>"; };
+ 3F8169301ABB7A6D001DA9DF /* SystemLifetimeManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemLifetimeManager.cpp; path = source/Initialization/SystemLifetimeManager.cpp; sourceTree = "<group>"; };
+ 3F8169341ABB7A80001DA9DF /* SystemInitializer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemInitializer.h; path = include/lldb/Initialization/SystemInitializer.h; sourceTree = "<group>"; };
+ 3F8169351ABB7A80001DA9DF /* SystemInitializerCommon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemInitializerCommon.h; path = include/lldb/Initialization/SystemInitializerCommon.h; sourceTree = "<group>"; };
+ 3F8169361ABB7A80001DA9DF /* SystemLifetimeManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemLifetimeManager.h; path = include/lldb/Initialization/SystemLifetimeManager.h; sourceTree = "<group>"; };
3FDFD6C3199C396E009756A7 /* FileAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileAction.h; path = include/lldb/Target/FileAction.h; sourceTree = "<group>"; };
3FDFDDBC199C3A06009756A7 /* FileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileAction.cpp; path = source/Target/FileAction.cpp; sourceTree = "<group>"; };
3FDFDDBE199D345E009756A7 /* FileCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileCache.cpp; path = source/Host/common/FileCache.cpp; sourceTree = "<group>"; };
@@ -3326,6 +3335,8 @@
94235B9B1A8D5FF300EB2EED /* SBVariablesOptions.cpp */,
B2A58721143119810092BFBA /* SBWatchpoint.h */,
B2A58723143119D50092BFBA /* SBWatchpoint.cpp */,
+ 3F81692D1ABB7A40001DA9DF /* SystemInitializerFull.h */,
+ 3F81692A1ABB7A16001DA9DF /* SystemInitializerFull.cpp */,
);
name = API;
sourceTree = "<group>";
@@ -4783,8 +4794,12 @@
3F8169261ABB73C1001DA9DF /* Initialization */ = {
isa = PBXGroup;
children = (
- 3F8169291ABB73E6001DA9DF /* InitializeLLDB.h */,
- 3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */,
+ 3F8169341ABB7A80001DA9DF /* SystemInitializer.h */,
+ 3F81692E1ABB7A6D001DA9DF /* SystemInitializer.cpp */,
+ 3F8169351ABB7A80001DA9DF /* SystemInitializerCommon.h */,
+ 3F81692F1ABB7A6D001DA9DF /* SystemInitializerCommon.cpp */,
+ 3F8169361ABB7A80001DA9DF /* SystemLifetimeManager.h */,
+ 3F8169301ABB7A6D001DA9DF /* SystemLifetimeManager.cpp */,
);
name = Initialization;
sourceTree = "<group>";
@@ -5810,6 +5825,7 @@
26680324116005D9008E1FE4 /* SBThread.cpp in Sources */,
26680326116005DB008E1FE4 /* SBTarget.cpp in Sources */,
26680327116005DC008E1FE4 /* SBSourceManager.cpp in Sources */,
+ 3F81692C1ABB7A1E001DA9DF /* SystemInitializerFull.cpp in Sources */,
26680328116005DE008E1FE4 /* SBProcess.cpp in Sources */,
2668032A116005E0008E1FE4 /* SBListener.cpp in Sources */,
2668032C116005E2008E1FE4 /* SBFrame.cpp in Sources */,
@@ -5927,6 +5943,7 @@
2689002413353DDE00698AC0 /* CommandObjectSettings.cpp in Sources */,
2689002513353DDE00698AC0 /* CommandObjectSource.cpp in Sources */,
2689002613353DDE00698AC0 /* CommandObjectSyntax.cpp in Sources */,
+ 3F8169331ABB7A6D001DA9DF /* SystemLifetimeManager.cpp in Sources */,
4959511F1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp in Sources */,
26BC179918C7F2B300D2196D /* JITLoader.cpp in Sources */,
2689002713353DDE00698AC0 /* CommandObjectTarget.cpp in Sources */,
@@ -5995,6 +6012,7 @@
8CCB017E19BA28A80009FD44 /* ThreadCollection.cpp in Sources */,
2689005613353E0400698AC0 /* Value.cpp in Sources */,
2689005713353E0400698AC0 /* ValueObject.cpp in Sources */,
+ 3F8169321ABB7A6D001DA9DF /* SystemInitializerCommon.cpp in Sources */,
2689005813353E0400698AC0 /* ValueObjectChild.cpp in Sources */,
E7723D441AC4A7FB002BA082 /* RegisterContextPOSIXCore_arm64.cpp in Sources */,
233B007F1960CB280090E598 /* ProcessLaunchInfo.cpp in Sources */,
@@ -6086,6 +6104,7 @@
268900B013353E5000698AC0 /* RegisterContextLLDB.cpp in Sources */,
3FDFE56C19AF9C44009756A7 /* HostProcessPosix.cpp in Sources */,
268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */,
+ 3F8169311ABB7A6D001DA9DF /* SystemInitializer.cpp in Sources */,
3FDFED2D19C257A0009756A7 /* HostProcess.cpp in Sources */,
268900B513353E5000698AC0 /* StopInfoMachException.cpp in Sources */,
268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */,
@@ -6377,7 +6396,6 @@
94CB257216B0A4270059775D /* TypeSynthetic.cpp in Sources */,
94CB257416B1D3880059775D /* FormatCache.cpp in Sources */,
A36FF33C17D8E94600244D40 /* OptionParser.cpp in Sources */,
- 3F8169281ABB73D9001DA9DF /* InitializeLLDB.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Tue Mar 31 16:03:22 2015
@@ -66,6 +66,7 @@ add_lldb_library(liblldb SHARED
SBVariablesOptions.cpp
SBWatchpoint.cpp
SBUnixSignals.cpp
+ SystemInitializerFull.cpp
${LLDB_WRAP_PYTHON}
${LLDB_VERS_GENERATED_FILE}
)
Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/trunk/source/API/SBCommandInterpreter.cpp Tue Mar 31 16:03:22 2015
@@ -588,183 +588,6 @@ SBCommandInterpreter::SetCommandOverride
return false;
}
-#ifndef LLDB_DISABLE_PYTHON
-
-// Defined in the SWIG source file
-extern "C" void
-init_lldb(void);
-
-// these are the Pythonic implementations of the required callbacks
-// these are scripting-language specific, which is why they belong here
-// we still need to use function pointers to them instead of relying
-// on linkage-time resolution because the SWIG stuff and this file
-// get built at different times
-extern "C" bool
-LLDBSwigPythonBreakpointCallbackFunction (const char *python_function_name,
- const char *session_dictionary_name,
- const lldb::StackFrameSP& sb_frame,
- const lldb::BreakpointLocationSP& sb_bp_loc);
-
-extern "C" bool
-LLDBSwigPythonWatchpointCallbackFunction (const char *python_function_name,
- const char *session_dictionary_name,
- const lldb::StackFrameSP& sb_frame,
- const lldb::WatchpointSP& sb_wp);
-
-extern "C" bool
-LLDBSwigPythonCallTypeScript (const char *python_function_name,
- void *session_dictionary,
- const lldb::ValueObjectSP& valobj_sp,
- void** pyfunct_wrapper,
- const lldb::TypeSummaryOptionsSP& options_sp,
- std::string& retval);
-
-extern "C" void*
-LLDBSwigPythonCreateSyntheticProvider (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ValueObjectSP& valobj_sp);
-
-extern "C" void*
-LLDBSwigPythonCreateCommandObject (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::DebuggerSP debugger_sp);
-
-extern "C" void*
-LLDBSwigPythonCreateScriptedThreadPlan (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ThreadPlanSP& thread_plan_sp);
-
-extern "C" bool
-LLDBSWIGPythonCallThreadPlan (void *implementor,
- const char *method_name,
- Event *event_sp,
- bool &got_error);
-
-extern "C" size_t
-LLDBSwigPython_CalculateNumChildren (void *implementor);
-
-extern "C" void *
-LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx);
-
-extern "C" int
-LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name);
-
-extern "C" void *
-LLDBSWIGPython_CastPyObjectToSBValue (void* data);
-
-extern lldb::ValueObjectSP
-LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data);
-
-extern "C" bool
-LLDBSwigPython_UpdateSynthProviderInstance (void* implementor);
-
-extern "C" bool
-LLDBSwigPython_MightHaveChildrenSynthProviderInstance (void* implementor);
-
-extern "C" void *
-LLDBSwigPython_GetValueSynthProviderInstance (void* implementor);
-
-extern "C" bool
-LLDBSwigPythonCallCommand (const char *python_function_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP& debugger,
- const char* args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
-extern "C" bool
-LLDBSwigPythonCallCommandObject (void *implementor,
- lldb::DebuggerSP& debugger,
- const char* args,
- lldb_private::CommandReturnObject& cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
-extern "C" bool
-LLDBSwigPythonCallModuleInit (const char *python_module_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP& debugger);
-
-extern "C" void*
-LLDBSWIGPythonCreateOSPlugin (const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ProcessSP& process_sp);
-
-extern "C" bool
-LLDBSWIGPythonRunScriptKeywordProcess (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ProcessSP& process,
- std::string& output);
-
-extern "C" bool
-LLDBSWIGPythonRunScriptKeywordThread (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ThreadSP& thread,
- std::string& output);
-
-extern "C" bool
-LLDBSWIGPythonRunScriptKeywordTarget (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::TargetSP& target,
- std::string& output);
-
-extern "C" bool
-LLDBSWIGPythonRunScriptKeywordFrame (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::StackFrameSP& frame,
- std::string& output);
-
-extern "C" bool
-LLDBSWIGPythonRunScriptKeywordValue (const char* python_function_name,
- const char* session_dictionary_name,
- lldb::ValueObjectSP& value,
- std::string& output);
-
-extern "C" void*
-LLDBSWIGPython_GetDynamicSetting (void* module,
- const char* setting,
- const lldb::TargetSP& target_sp);
-
-
-#endif
-
-void
-SBCommandInterpreter::InitializeSWIG ()
-{
- static bool g_initialized = false;
- if (!g_initialized)
- {
- g_initialized = true;
-#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreter::InitializeInterpreter (init_lldb,
- LLDBSwigPythonBreakpointCallbackFunction,
- LLDBSwigPythonWatchpointCallbackFunction,
- LLDBSwigPythonCallTypeScript,
- LLDBSwigPythonCreateSyntheticProvider,
- LLDBSwigPythonCreateCommandObject,
- LLDBSwigPython_CalculateNumChildren,
- LLDBSwigPython_GetChildAtIndex,
- LLDBSwigPython_GetIndexOfChildWithName,
- LLDBSWIGPython_CastPyObjectToSBValue,
- LLDBSWIGPython_GetValueObjectSPFromSBValue,
- LLDBSwigPython_UpdateSynthProviderInstance,
- LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
- LLDBSwigPython_GetValueSynthProviderInstance,
- LLDBSwigPythonCallCommand,
- LLDBSwigPythonCallCommandObject,
- LLDBSwigPythonCallModuleInit,
- LLDBSWIGPythonCreateOSPlugin,
- LLDBSWIGPythonRunScriptKeywordProcess,
- LLDBSWIGPythonRunScriptKeywordThread,
- LLDBSWIGPythonRunScriptKeywordTarget,
- LLDBSWIGPythonRunScriptKeywordFrame,
- LLDBSWIGPythonRunScriptKeywordValue,
- LLDBSWIGPython_GetDynamicSetting,
- LLDBSwigPythonCreateScriptedThreadPlan,
- LLDBSWIGPythonCallThreadPlan);
-#endif
- }
-}
-
lldb::SBCommand
SBCommandInterpreter::AddMultiwordCommand (const char* name, const char* help)
{
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Tue Mar 31 16:03:22 2015
@@ -13,6 +13,7 @@
#include "lldb/lldb-private.h"
+#include "lldb/API/SystemInitializerFull.h"
#include "lldb/API/SBListener.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBCommandInterpreter.h"
@@ -37,42 +38,20 @@
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/DataFormatters/DataVisualization.h"
-#include "lldb/Initialization/InitializeLLDB.h"
+#include "lldb/Initialization/SystemLifetimeManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
+#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/DynamicLibrary.h"
using namespace lldb;
using namespace lldb_private;
-SBInputReader::SBInputReader()
-{
-}
-SBInputReader::~SBInputReader()
-{
-}
-
-SBError
-SBInputReader::Initialize(lldb::SBDebugger& sb_debugger, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool)
-{
- return SBError();
-}
-
-void
-SBInputReader::SetIsDone(bool)
-{
-}
-bool
-SBInputReader::IsActive() const
-{
- return false;
-}
-
static llvm::sys::DynamicLibrary
LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error)
{
@@ -107,6 +86,34 @@ LoadPlugin (const lldb::DebuggerSP &debu
return llvm::sys::DynamicLibrary();
}
+static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime;
+
+SBInputReader::SBInputReader()
+{
+}
+SBInputReader::~SBInputReader()
+{
+}
+
+SBError
+SBInputReader::Initialize(lldb::SBDebugger &sb_debugger,
+ unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, char const *,
+ unsigned long),
+ void *, lldb::InputReaderGranularity, char const *, char const *, bool)
+{
+ return SBError();
+}
+
+void
+SBInputReader::SetIsDone(bool)
+{
+}
+bool
+SBInputReader::IsActive() const
+{
+ return false;
+}
+
void
SBDebugger::Initialize ()
{
@@ -115,15 +122,13 @@ SBDebugger::Initialize ()
if (log)
log->Printf ("SBDebugger::Initialize ()");
- SBCommandInterpreter::InitializeSWIG ();
-
- lldb_private::Initialize(LoadPlugin);
+ g_debugger_lifetime->Initialize(llvm::make_unique<SystemInitializerFull>(), LoadPlugin);
}
void
SBDebugger::Terminate ()
{
- lldb_private::Terminate();
+ g_debugger_lifetime->Terminate();
}
void
Added: lldb/trunk/source/API/SystemInitializerFull.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.cpp?rev=233758&view=auto
==============================================================================
--- lldb/trunk/source/API/SystemInitializerFull.cpp (added)
+++ lldb/trunk/source/API/SystemInitializerFull.cpp Tue Mar 31 16:03:22 2015
@@ -0,0 +1,394 @@
+//===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/API/SystemInitializerFull.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Timer.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Initialization/SystemInitializerCommon.h"
+
+#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
+#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
+#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
+#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
+#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
+#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
+#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
+#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
+#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
+#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
+#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
+#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
+#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
+#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
+#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
+#include "Plugins/Process/elf-core/ProcessElfCore.h"
+#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
+#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
+#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
+#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
+
+#if defined(__APPLE__)
+#include "Plugins/Process/mach-core/ProcessMachCore.h"
+#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
+#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
+#endif
+
+#if defined(__FreeBSD__)
+#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
+#endif
+
+#if defined(__linux__)
+#include "Plugins/Process/Linux/ProcessLinux.h"
+#endif
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
+#include "Plugins/Process/Windows/ProcessWindows.h"
+#endif
+
+#if !defined(LLDB_DISABLE_PYTHON)
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#endif
+
+#include "llvm/Support/TargetSelect.h"
+
+#include <string>
+
+using namespace lldb_private;
+
+#ifndef LLDB_DISABLE_PYTHON
+
+// Defined in the SWIG source file
+extern "C" void
+init_lldb(void);
+
+// these are the Pythonic implementations of the required callbacks
+// these are scripting-language specific, which is why they belong here
+// we still need to use function pointers to them instead of relying
+// on linkage-time resolution because the SWIG stuff and this file
+// get built at different times
+extern "C" bool
+LLDBSwigPythonBreakpointCallbackFunction (const char *python_function_name,
+ const char *session_dictionary_name,
+ const lldb::StackFrameSP& sb_frame,
+ const lldb::BreakpointLocationSP& sb_bp_loc);
+
+extern "C" bool
+LLDBSwigPythonWatchpointCallbackFunction (const char *python_function_name,
+ const char *session_dictionary_name,
+ const lldb::StackFrameSP& sb_frame,
+ const lldb::WatchpointSP& sb_wp);
+
+extern "C" bool
+LLDBSwigPythonCallTypeScript (const char *python_function_name,
+ void *session_dictionary,
+ const lldb::ValueObjectSP& valobj_sp,
+ void** pyfunct_wrapper,
+ const lldb::TypeSummaryOptionsSP& options_sp,
+ std::string& retval);
+
+extern "C" void*
+LLDBSwigPythonCreateSyntheticProvider (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ValueObjectSP& valobj_sp);
+
+extern "C" void*
+LLDBSwigPythonCreateCommandObject (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::DebuggerSP debugger_sp);
+
+extern "C" void*
+LLDBSwigPythonCreateScriptedThreadPlan (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ThreadPlanSP& thread_plan_sp);
+
+extern "C" bool
+LLDBSWIGPythonCallThreadPlan (void *implementor,
+ const char *method_name,
+ Event *event_sp,
+ bool &got_error);
+
+extern "C" size_t
+LLDBSwigPython_CalculateNumChildren (void *implementor);
+
+extern "C" void *
+LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx);
+
+extern "C" int
+LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name);
+
+extern "C" void *
+LLDBSWIGPython_CastPyObjectToSBValue (void* data);
+
+extern lldb::ValueObjectSP
+LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data);
+
+extern "C" bool
+LLDBSwigPython_UpdateSynthProviderInstance (void* implementor);
+
+extern "C" bool
+LLDBSwigPython_MightHaveChildrenSynthProviderInstance (void* implementor);
+
+extern "C" void *
+LLDBSwigPython_GetValueSynthProviderInstance (void* implementor);
+
+extern "C" bool
+LLDBSwigPythonCallCommand (const char *python_function_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP& debugger,
+ const char* args,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+extern "C" bool
+LLDBSwigPythonCallCommandObject (void *implementor,
+ lldb::DebuggerSP& debugger,
+ const char* args,
+ lldb_private::CommandReturnObject& cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+extern "C" bool
+LLDBSwigPythonCallModuleInit (const char *python_module_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP& debugger);
+
+extern "C" void*
+LLDBSWIGPythonCreateOSPlugin (const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ProcessSP& process_sp);
+
+extern "C" bool
+LLDBSWIGPythonRunScriptKeywordProcess (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::ProcessSP& process,
+ std::string& output);
+
+extern "C" bool
+LLDBSWIGPythonRunScriptKeywordThread (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::ThreadSP& thread,
+ std::string& output);
+
+extern "C" bool
+LLDBSWIGPythonRunScriptKeywordTarget (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::TargetSP& target,
+ std::string& output);
+
+extern "C" bool
+LLDBSWIGPythonRunScriptKeywordFrame (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::StackFrameSP& frame,
+ std::string& output);
+
+extern "C" bool
+LLDBSWIGPythonRunScriptKeywordValue (const char* python_function_name,
+ const char* session_dictionary_name,
+ lldb::ValueObjectSP& value,
+ std::string& output);
+
+extern "C" void*
+LLDBSWIGPython_GetDynamicSetting (void* module,
+ const char* setting,
+ const lldb::TargetSP& target_sp);
+
+
+#endif
+
+SystemInitializerFull::SystemInitializerFull()
+{
+}
+
+SystemInitializerFull::~SystemInitializerFull()
+{
+}
+
+void
+SystemInitializerFull::Initialize()
+{
+ InitializeSWIG();
+
+ SystemInitializerCommon::Initialize();
+
+ // Initialize LLVM and Clang
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllAsmPrinters();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllDisassemblers();
+
+ ABIMacOSX_i386::Initialize();
+ ABIMacOSX_arm::Initialize();
+ ABIMacOSX_arm64::Initialize();
+ ABISysV_x86_64::Initialize();
+ ABISysV_ppc::Initialize();
+ ABISysV_ppc64::Initialize();
+ DisassemblerLLVMC::Initialize();
+
+ JITLoaderGDB::Initialize();
+ ProcessElfCore::Initialize();
+ MemoryHistoryASan::Initialize();
+ AddressSanitizerRuntime::Initialize();
+
+ SymbolVendorELF::Initialize();
+ SymbolFileDWARF::Initialize();
+ SymbolFileSymtab::Initialize();
+ UnwindAssemblyInstEmulation::Initialize();
+ UnwindAssembly_x86::Initialize();
+ EmulateInstructionARM::Initialize();
+ EmulateInstructionARM64::Initialize();
+ EmulateInstructionMIPS64::Initialize();
+ SymbolFileDWARFDebugMap::Initialize();
+ ItaniumABILanguageRuntime::Initialize();
+ AppleObjCRuntimeV2::Initialize();
+ AppleObjCRuntimeV1::Initialize();
+ SystemRuntimeMacOSX::Initialize();
+
+#if defined(__linux__)
+ //----------------------------------------------------------------------
+ // Linux hosted plugins
+ //----------------------------------------------------------------------
+ ProcessLinux::Initialize();
+#endif
+#if defined(_MSC_VER)
+ DynamicLoaderWindows::Initialize();
+ ProcessWindows::Initialize();
+#endif
+#if defined(__FreeBSD__)
+ ProcessFreeBSD::Initialize();
+#endif
+#if defined(__APPLE__)
+ SymbolVendorMacOSX::Initialize();
+ ProcessKDP::Initialize();
+ ProcessMachCore::Initialize();
+#endif
+ //----------------------------------------------------------------------
+ // Platform agnostic plugins
+ //----------------------------------------------------------------------
+ platform_gdb_server::PlatformRemoteGDBServer::Initialize();
+
+ process_gdb_remote::ProcessGDBRemote::Initialize();
+ DynamicLoaderStatic::Initialize();
+
+ // Scan for any system or user LLDB plug-ins
+ PluginManager::Initialize();
+
+ // The process settings need to know about installed plug-ins, so the Settings must be initialized
+ // AFTER PluginManager::Initialize is called.
+
+ Debugger::SettingsInitialize();
+}
+
+void SystemInitializerFull::InitializeSWIG()
+{
+#if !defined(LLDB_DISABLE_PYTHON)
+ ScriptInterpreterPython::InitializeInterpreter(
+ init_lldb,
+ LLDBSwigPythonBreakpointCallbackFunction,
+ LLDBSwigPythonWatchpointCallbackFunction,
+ LLDBSwigPythonCallTypeScript,
+ LLDBSwigPythonCreateSyntheticProvider,
+ LLDBSwigPythonCreateCommandObject,
+ LLDBSwigPython_CalculateNumChildren,
+ LLDBSwigPython_GetChildAtIndex,
+ LLDBSwigPython_GetIndexOfChildWithName,
+ LLDBSWIGPython_CastPyObjectToSBValue,
+ LLDBSWIGPython_GetValueObjectSPFromSBValue,
+ LLDBSwigPython_UpdateSynthProviderInstance,
+ LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
+ LLDBSwigPython_GetValueSynthProviderInstance,
+ LLDBSwigPythonCallCommand,
+ LLDBSwigPythonCallCommandObject,
+ LLDBSwigPythonCallModuleInit,
+ LLDBSWIGPythonCreateOSPlugin,
+ LLDBSWIGPythonRunScriptKeywordProcess,
+ LLDBSWIGPythonRunScriptKeywordThread,
+ LLDBSWIGPythonRunScriptKeywordTarget,
+ LLDBSWIGPythonRunScriptKeywordFrame,
+ LLDBSWIGPythonRunScriptKeywordValue,
+ LLDBSWIGPython_GetDynamicSetting,
+ LLDBSwigPythonCreateScriptedThreadPlan,
+ LLDBSWIGPythonCallThreadPlan);
+#endif
+}
+
+void
+SystemInitializerFull::Terminate()
+{
+ Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+
+ Debugger::SettingsTerminate();
+
+ // Terminate and unload and loaded system or user LLDB plug-ins
+ PluginManager::Terminate();
+ ABIMacOSX_i386::Terminate();
+ ABIMacOSX_arm::Terminate();
+ ABIMacOSX_arm64::Terminate();
+ ABISysV_x86_64::Terminate();
+ ABISysV_ppc::Terminate();
+ ABISysV_ppc64::Terminate();
+ DisassemblerLLVMC::Terminate();
+
+ JITLoaderGDB::Terminate();
+ ProcessElfCore::Terminate();
+ MemoryHistoryASan::Terminate();
+ AddressSanitizerRuntime::Terminate();
+ SymbolVendorELF::Terminate();
+ SymbolFileDWARF::Terminate();
+ SymbolFileSymtab::Terminate();
+ UnwindAssembly_x86::Terminate();
+ UnwindAssemblyInstEmulation::Terminate();
+ EmulateInstructionARM::Terminate();
+ EmulateInstructionARM64::Terminate();
+ EmulateInstructionMIPS64::Terminate();
+ SymbolFileDWARFDebugMap::Terminate();
+ ItaniumABILanguageRuntime::Terminate();
+ AppleObjCRuntimeV2::Terminate();
+ AppleObjCRuntimeV1::Terminate();
+ SystemRuntimeMacOSX::Terminate();
+
+#if defined(__APPLE__)
+ ProcessMachCore::Terminate();
+ ProcessKDP::Terminate();
+ SymbolVendorMacOSX::Terminate();
+#endif
+#if defined(_MSC_VER)
+ DynamicLoaderWindows::Terminate();
+#endif
+
+#if defined(__linux__)
+ ProcessLinux::Terminate();
+#endif
+
+#if defined(__FreeBSD__)
+ ProcessFreeBSD::Terminate();
+#endif
+ Debugger::SettingsTerminate();
+
+ platform_gdb_server::PlatformRemoteGDBServer::Terminate();
+ process_gdb_remote::ProcessGDBRemote::Terminate();
+ DynamicLoaderStatic::Terminate();
+
+ // Now shutdown the common parts, in reverse order.
+ SystemInitializerCommon::Terminate();
+}
+
+void SystemInitializerFull::TerminateSWIG()
+{
+
+}
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Tue Mar 31 16:03:22 2015
@@ -38,7 +38,6 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Host/ThreadLauncher.h"
-#include "lldb/Initialization/InitializeLLDB.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueSInt64.h"
@@ -65,7 +64,6 @@ using namespace lldb;
using namespace lldb_private;
-static uint32_t g_shared_debugger_refcount = 0;
static lldb::user_id_t g_unique_id = 1;
static size_t g_debugger_event_thread_stack_bytes = 8 * 1024 * 1024;
@@ -407,35 +405,24 @@ Debugger::GetEscapeNonPrintables () cons
//}
//
-int
-Debugger::TestDebuggerRefCount ()
-{
- return g_shared_debugger_refcount;
-}
-
-static bool lldb_initialized = true;
+static bool lldb_initialized = false;
void
Debugger::Initialize(LoadPluginCallbackType load_plugin_callback)
{
+ assert(!lldb_initialized && "Debugger::Initialize called more than once!");
+
lldb_initialized = true;
- g_shared_debugger_refcount++;
g_load_plugin_callback = load_plugin_callback;
}
-int
+void
Debugger::Terminate ()
{
- if (g_shared_debugger_refcount > 0)
- {
- g_shared_debugger_refcount--;
- if (g_shared_debugger_refcount == 0)
- {
- // Clear our master list of debugger objects
- Mutex::Locker locker (GetDebuggerListMutex ());
- GetDebuggerList().clear();
- }
- }
- return g_shared_debugger_refcount;
+ assert(lldb_initialized && "Debugger::Terminate called without a matching Debugger::Initialize!");
+
+ // Clear our master list of debugger objects
+ Mutex::Locker locker (GetDebuggerListMutex ());
+ GetDebuggerList().clear();
}
void
@@ -568,7 +555,7 @@ DebuggerSP
Debugger::CreateInstance (lldb::LogOutputCallback log_callback, void *baton)
{
DebuggerSP debugger_sp (new Debugger(log_callback, baton));
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
GetDebuggerList().push_back(debugger_sp);
@@ -585,7 +572,7 @@ Debugger::Destroy (DebuggerSP &debugger_
debugger_sp->Clear();
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
DebuggerList &debugger_list = GetDebuggerList ();
@@ -605,7 +592,7 @@ DebuggerSP
Debugger::FindDebuggerWithInstanceName (const ConstString &instance_name)
{
DebuggerSP debugger_sp;
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
DebuggerList &debugger_list = GetDebuggerList();
@@ -627,7 +614,7 @@ TargetSP
Debugger::FindTargetWithProcessID (lldb::pid_t pid)
{
TargetSP target_sp;
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
DebuggerList &debugger_list = GetDebuggerList();
@@ -646,7 +633,7 @@ TargetSP
Debugger::FindTargetWithProcess (Process *process)
{
TargetSP target_sp;
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
DebuggerList &debugger_list = GetDebuggerList();
@@ -1129,7 +1116,7 @@ Debugger::GetAsyncErrorStream ()
size_t
Debugger::GetNumDebuggers()
{
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
return GetDebuggerList().size();
@@ -1142,7 +1129,7 @@ Debugger::GetDebuggerAtIndex (size_t ind
{
DebuggerSP debugger_sp;
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
DebuggerList &debugger_list = GetDebuggerList();
@@ -1159,7 +1146,7 @@ Debugger::FindDebuggerWithID (lldb::user
{
DebuggerSP debugger_sp;
- if (g_shared_debugger_refcount > 0)
+ if (lldb_initialized)
{
Mutex::Locker locker (GetDebuggerListMutex ());
DebuggerList &debugger_list = GetDebuggerList();
Modified: lldb/trunk/source/Initialization/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/CMakeLists.txt?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/source/Initialization/CMakeLists.txt (original)
+++ lldb/trunk/source/Initialization/CMakeLists.txt Tue Mar 31 16:03:22 2015
@@ -1,3 +1,5 @@
add_lldb_library(lldbInitialization
- InitializeLLDB.cpp
+ SystemInitializerCommon.cpp
+ SystemInitializer.cpp
+ SystemLifetimeManager.cpp
)
Removed: lldb/trunk/source/Initialization/InitializeLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/InitializeLLDB.cpp?rev=233757&view=auto
==============================================================================
--- lldb/trunk/source/Initialization/InitializeLLDB.cpp (original)
+++ lldb/trunk/source/Initialization/InitializeLLDB.cpp (removed)
@@ -1,400 +0,0 @@
-//===-- InitializeLLDB.cpp --------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/Mutex.h"
-#include "lldb/Initialization/InitializeLLDB.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-
-#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
-#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
-#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
-#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
-#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
-#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
-#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
-#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
-#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
-#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
-#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
-#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
-#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
-#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
-#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
-#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
-#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
-#include "Plugins/Platform/Android/PlatformAndroid.h"
-#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
-#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
-#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
-#include "Plugins/Platform/Linux/PlatformLinux.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
-#include "Plugins/Platform/Windows/PlatformWindows.h"
-#include "Plugins/Process/elf-core/ProcessElfCore.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
-#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
-#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
-#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
-#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
-
-#if defined(__APPLE__)
-#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
-#include "Plugins/Process/mach-core/ProcessMachCore.h"
-#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
-#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
-#endif
-
-#if defined(__FreeBSD__)
-#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
-#endif
-
-#if defined(__linux__)
-#include "Plugins/Process/Linux/ProcessLinux.h"
-#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
-#endif
-
-#if defined(_MSC_VER)
-#include "lldb/Host/windows/windows.h"
-#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
-#include "Plugins/Process/Windows/ProcessWindows.h"
-#endif
-
-#include "llvm/Support/TargetSelect.h"
-
-#include <string>
-
-using namespace lldb_private;
-
-static void
-fatal_error_handler(void *user_data, const std::string &reason, bool gen_crash_diag)
-{
- Host::SetCrashDescription(reason.c_str());
- ::abort();
-}
-
-static bool g_inited_for_llgs = false;
-static void
-InitializeForLLGSPrivate()
-{
- if (g_inited_for_llgs)
- return;
- g_inited_for_llgs = true;
-
-#if defined(_MSC_VER)
- const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
- if (disable_crash_dialog_var && llvm::StringRef(disable_crash_dialog_var).equals_lower("true"))
- {
- // This will prevent Windows from displaying a dialog box requiring user interaction when
- // LLDB crashes. This is mostly useful when automating LLDB, for example via the test
- // suite, so that a crash in LLDB does not prevent completion of the test suite.
- ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
-
- _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
- }
-#endif
-
- Log::Initialize();
- HostInfo::Initialize();
- Timer::Initialize();
- Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
- llvm::install_fatal_error_handler(fatal_error_handler, 0);
-
- process_gdb_remote::ProcessGDBRemoteLog::Initialize();
-
- // Initialize plug-ins
- ObjectContainerBSDArchive::Initialize();
- ObjectFileELF::Initialize();
- ObjectFilePECOFF::Initialize();
- DynamicLoaderPOSIXDYLD::Initialize();
- PlatformFreeBSD::Initialize();
- platform_linux::PlatformLinux::Initialize();
- PlatformWindows::Initialize();
- PlatformKalimba::Initialize();
- platform_android::PlatformAndroid::Initialize();
-
- //----------------------------------------------------------------------
- // Apple/Darwin hosted plugins
- //----------------------------------------------------------------------
- DynamicLoaderMacOSXDYLD::Initialize();
- ObjectContainerUniversalMachO::Initialize();
-
- PlatformRemoteiOS::Initialize();
- PlatformMacOSX::Initialize();
- PlatformiOSSimulator::Initialize();
-
-#if defined(__APPLE__)
- DynamicLoaderDarwinKernel::Initialize();
- PlatformDarwinKernel::Initialize();
- ObjectFileMachO::Initialize();
-#endif
-#if defined(__linux__)
- static ConstString g_linux_log_name("linux");
- ProcessPOSIXLog::Initialize(g_linux_log_name);
-#endif
-#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreterPython::InitializePrivate();
- OperatingSystemPython::Initialize();
-#endif
-}
-
-static bool g_inited = false;
-static void
-InitializePrivate()
-{
- if (g_inited)
- return;
- g_inited = true;
-
- InitializeForLLGSPrivate();
-
- // Initialize LLVM and Clang
- llvm::InitializeAllTargets();
- llvm::InitializeAllAsmPrinters();
- llvm::InitializeAllTargetMCs();
- llvm::InitializeAllDisassemblers();
-
- ABIMacOSX_i386::Initialize();
- ABIMacOSX_arm::Initialize();
- ABIMacOSX_arm64::Initialize();
- ABISysV_x86_64::Initialize();
- ABISysV_ppc::Initialize();
- ABISysV_ppc64::Initialize();
- DisassemblerLLVMC::Initialize();
-
- JITLoaderGDB::Initialize();
- ProcessElfCore::Initialize();
- MemoryHistoryASan::Initialize();
- AddressSanitizerRuntime::Initialize();
-
- SymbolVendorELF::Initialize();
- SymbolFileDWARF::Initialize();
- SymbolFileSymtab::Initialize();
- UnwindAssemblyInstEmulation::Initialize();
- UnwindAssembly_x86::Initialize();
- EmulateInstructionARM::Initialize();
- EmulateInstructionARM64::Initialize();
- EmulateInstructionMIPS64::Initialize();
- SymbolFileDWARFDebugMap::Initialize();
- ItaniumABILanguageRuntime::Initialize();
- AppleObjCRuntimeV2::Initialize();
- AppleObjCRuntimeV1::Initialize();
- SystemRuntimeMacOSX::Initialize();
-
-#if defined(__linux__)
- //----------------------------------------------------------------------
- // Linux hosted plugins
- //----------------------------------------------------------------------
- process_linux::ProcessLinux::Initialize();
-#endif
-#if defined(_MSC_VER)
- DynamicLoaderWindows::Initialize();
- ProcessWindows::Initialize();
-#endif
-#if defined(__FreeBSD__)
- ProcessFreeBSD::Initialize();
-#endif
-#if defined(__APPLE__)
- SymbolVendorMacOSX::Initialize();
- ProcessKDP::Initialize();
- ProcessMachCore::Initialize();
-#endif
- //----------------------------------------------------------------------
- // Platform agnostic plugins
- //----------------------------------------------------------------------
- platform_gdb_server::PlatformRemoteGDBServer::Initialize();
-
- process_gdb_remote::ProcessGDBRemote::Initialize();
- DynamicLoaderStatic::Initialize();
-
- // Scan for any system or user LLDB plug-ins
- PluginManager::Initialize();
-
- // The process settings need to know about installed plug-ins, so the Settings must be initialized
- // AFTER PluginManager::Initialize is called.
-
- Debugger::SettingsInitialize();
-}
-
-static void
-TerminateForLLGSPrivate()
-{
- if (!g_inited_for_llgs)
- return;
- g_inited_for_llgs = false;
-
- Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- ObjectContainerBSDArchive::Terminate();
- ObjectFileELF::Terminate();
- ObjectFilePECOFF::Terminate();
- DynamicLoaderPOSIXDYLD::Terminate();
- PlatformFreeBSD::Terminate();
- platform_linux::PlatformLinux::Terminate();
- PlatformWindows::Terminate();
- PlatformKalimba::Terminate();
- platform_android::PlatformAndroid::Terminate();
- DynamicLoaderMacOSXDYLD::Terminate();
- ObjectContainerUniversalMachO::Terminate();
- PlatformMacOSX::Terminate();
- PlatformRemoteiOS::Terminate();
- PlatformiOSSimulator::Terminate();
-
-#if defined(__APPLE__)
- DynamicLoaderDarwinKernel::Terminate();
- ObjectFileMachO::Terminate();
- PlatformDarwinKernel::Terminate();
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
- OperatingSystemPython::Terminate();
-#endif
-
- Log::Terminate();
-}
-
-static void
-TerminatePrivate()
-{
-
- if (!g_inited)
- return;
- g_inited = false;
-
- Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- // Terminate and unload and loaded system or user LLDB plug-ins
- PluginManager::Terminate();
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
- ABIMacOSX_arm64::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
- DisassemblerLLVMC::Terminate();
-
- JITLoaderGDB::Terminate();
- ProcessElfCore::Terminate();
- MemoryHistoryASan::Terminate();
- AddressSanitizerRuntime::Terminate();
- SymbolVendorELF::Terminate();
- SymbolFileDWARF::Terminate();
- SymbolFileSymtab::Terminate();
- UnwindAssembly_x86::Terminate();
- UnwindAssemblyInstEmulation::Terminate();
- EmulateInstructionARM::Terminate();
- EmulateInstructionARM64::Terminate();
- EmulateInstructionMIPS64::Terminate();
- SymbolFileDWARFDebugMap::Terminate();
- ItaniumABILanguageRuntime::Terminate();
- AppleObjCRuntimeV2::Terminate();
- AppleObjCRuntimeV1::Terminate();
- SystemRuntimeMacOSX::Terminate();
-
-#if defined(__APPLE__)
- ProcessMachCore::Terminate();
- ProcessKDP::Terminate();
- SymbolVendorMacOSX::Terminate();
-#endif
-#if defined(_MSC_VER)
- DynamicLoaderWindows::Terminate();
-#endif
-
-#if defined(__linux__)
- process_linux::ProcessLinux::Terminate();
-#endif
-
-#if defined(__FreeBSD__)
- ProcessFreeBSD::Terminate();
-#endif
- Debugger::SettingsTerminate();
-
- platform_gdb_server::PlatformRemoteGDBServer::Terminate();
- process_gdb_remote::ProcessGDBRemote::Terminate();
- DynamicLoaderStatic::Terminate();
-
- TerminateForLLGSPrivate();
-}
-
-void
-lldb_private::InitializeForLLGS(LoadPluginCallbackType load_plugin_callback)
-{
- // Make sure we initialize only once
- static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
- Mutex::Locker locker(g_inited_mutex);
-
- // Call the actual initializers. If we've already been initialized this
- // will do nothing.
- InitializeForLLGSPrivate();
-
- // We want to call Debuger::Initialize every time, even if we've already
- // been initialized, so that the debugger ref count increases.
- Debugger::Initialize(load_plugin_callback);
-}
-
-void
-lldb_private::Initialize(LoadPluginCallbackType load_plugin_callback)
-{
- // Make sure we initialize only once
- static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
- Mutex::Locker locker(g_inited_mutex);
-
- // Call the actual initializers. If we've already been initialized this
- // will do nothing.
- InitializeForLLGSPrivate();
- InitializePrivate();
-
- // We want to call Debuger::Initialize every time, even if we've already
- // been initialized, so that the debugger ref count increases.
- Debugger::Initialize(load_plugin_callback);
-}
-
-void
-lldb_private::TerminateLLGS()
-{
- // Terminate the debugger. If the ref count is still greater than 0, we
- // shouldn't shutdown yet.
- if (Debugger::Terminate() > 0)
- return;
-
- TerminateForLLGSPrivate();
-}
-
-void
-lldb_private::Terminate()
-{
- // Terminate the debugger. If the ref count is still greater than 0, we
- // shouldn't shutdown yet.
- if (Debugger::Terminate() > 0)
- return;
-
- TerminatePrivate();
-}
Added: lldb/trunk/source/Initialization/SystemInitializer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializer.cpp?rev=233758&view=auto
==============================================================================
--- lldb/trunk/source/Initialization/SystemInitializer.cpp (added)
+++ lldb/trunk/source/Initialization/SystemInitializer.cpp Tue Mar 31 16:03:22 2015
@@ -0,0 +1,20 @@
+//===-- SystemInitializer.cpp -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Initialization/SystemInitializer.h"
+
+using namespace lldb_private;
+
+SystemInitializer::SystemInitializer()
+{
+}
+
+SystemInitializer::~SystemInitializer()
+{
+}
Added: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializerCommon.cpp?rev=233758&view=auto
==============================================================================
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp (added)
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp Tue Mar 31 16:03:22 2015
@@ -0,0 +1,167 @@
+//===-- SystemInitializerCommon.cpp -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Initialization/SystemInitializerCommon.h"
+
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Timer.h"
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
+
+#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
+#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
+#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
+#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
+#include "Plugins/Platform/Android/PlatformAndroid.h"
+#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
+#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
+#include "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
+#include "Plugins/Platform/Windows/PlatformWindows.h"
+#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
+
+#if defined(__APPLE__)
+#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
+#endif
+
+#if defined(__linux__)
+#include "Plugins/Process/Linux/ProcessLinux.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#endif
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#endif
+
+#include "llvm/Support/TargetSelect.h"
+
+#include <string>
+
+using namespace lldb_private;
+
+static void
+fatal_error_handler(void *user_data, const std::string &reason, bool gen_crash_diag)
+{
+ Host::SetCrashDescription(reason.c_str());
+ ::abort();
+}
+
+SystemInitializerCommon::SystemInitializerCommon()
+{
+}
+
+SystemInitializerCommon::~SystemInitializerCommon()
+{
+}
+
+void
+SystemInitializerCommon::Initialize()
+{
+#if defined(_MSC_VER)
+ const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
+ if (disable_crash_dialog_var && llvm::StringRef(disable_crash_dialog_var).equals_lower("true"))
+ {
+ // This will prevent Windows from displaying a dialog box requiring user interaction when
+ // LLDB crashes. This is mostly useful when automating LLDB, for example via the test
+ // suite, so that a crash in LLDB does not prevent completion of the test suite.
+ ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
+
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ }
+#endif
+
+ Log::Initialize();
+ HostInfo::Initialize();
+ Timer::Initialize();
+ Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+
+ llvm::install_fatal_error_handler(fatal_error_handler, 0);
+
+ process_gdb_remote::ProcessGDBRemoteLog::Initialize();
+
+ // Initialize plug-ins
+ ObjectContainerBSDArchive::Initialize();
+ ObjectFileELF::Initialize();
+ ObjectFilePECOFF::Initialize();
+ DynamicLoaderPOSIXDYLD::Initialize();
+ PlatformFreeBSD::Initialize();
+ platform_linux::PlatformLinux::Initialize();
+ PlatformWindows::Initialize();
+ PlatformKalimba::Initialize();
+ platform_android::PlatformAndroid::Initialize();
+
+ //----------------------------------------------------------------------
+ // Apple/Darwin hosted plugins
+ //----------------------------------------------------------------------
+ DynamicLoaderMacOSXDYLD::Initialize();
+ ObjectContainerUniversalMachO::Initialize();
+
+ PlatformRemoteiOS::Initialize();
+ PlatformMacOSX::Initialize();
+ PlatformiOSSimulator::Initialize();
+
+#if defined(__APPLE__)
+ DynamicLoaderDarwinKernel::Initialize();
+ PlatformDarwinKernel::Initialize();
+ ObjectFileMachO::Initialize();
+#endif
+#if defined(__linux__)
+ static ConstString g_linux_log_name("linux");
+ ProcessPOSIXLog::Initialize(g_linux_log_name);
+#endif
+#ifndef LLDB_DISABLE_PYTHON
+ ScriptInterpreterPython::InitializePrivate();
+ OperatingSystemPython::Initialize();
+#endif
+}
+
+void
+SystemInitializerCommon::Terminate()
+{
+ Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+ ObjectContainerBSDArchive::Terminate();
+ ObjectFileELF::Terminate();
+ ObjectFilePECOFF::Terminate();
+ DynamicLoaderPOSIXDYLD::Terminate();
+ PlatformFreeBSD::Terminate();
+ platform_linux::PlatformLinux::Terminate();
+ PlatformWindows::Terminate();
+ PlatformKalimba::Terminate();
+ platform_android::PlatformAndroid::Terminate();
+ DynamicLoaderMacOSXDYLD::Terminate();
+ ObjectContainerUniversalMachO::Terminate();
+ PlatformMacOSX::Terminate();
+ PlatformRemoteiOS::Terminate();
+ PlatformiOSSimulator::Terminate();
+
+#if defined(__APPLE__)
+ DynamicLoaderDarwinKernel::Terminate();
+ ObjectFileMachO::Terminate();
+ PlatformDarwinKernel::Terminate();
+#endif
+
+#ifndef LLDB_DISABLE_PYTHON
+ OperatingSystemPython::Terminate();
+#endif
+
+ Log::Terminate();
+}
Added: lldb/trunk/source/Initialization/SystemLifetimeManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemLifetimeManager.cpp?rev=233758&view=auto
==============================================================================
--- lldb/trunk/source/Initialization/SystemLifetimeManager.cpp (added)
+++ lldb/trunk/source/Initialization/SystemLifetimeManager.cpp Tue Mar 31 16:03:22 2015
@@ -0,0 +1,61 @@
+//===-- SystemLifetimeManager.cpp ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Initialization/SystemLifetimeManager.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Initialization/SystemInitializer.h"
+
+#include <utility>
+
+using namespace lldb_private;
+
+SystemLifetimeManager::SystemLifetimeManager()
+ : m_mutex(Mutex::eMutexTypeRecursive)
+ , m_initialized(false)
+{
+}
+
+SystemLifetimeManager::~SystemLifetimeManager()
+{
+ assert(!m_initialized && "SystemLifetimeManager destroyed without calling Terminate!");
+}
+
+void
+SystemLifetimeManager::Initialize(std::unique_ptr<SystemInitializer> initializer,
+ LoadPluginCallbackType plugin_callback)
+{
+ Mutex::Locker locker(m_mutex);
+ if (!m_initialized)
+ {
+ assert(!m_initializer &&
+ "Attempting to call SystemLifetimeManager::Initialize() when it is already initialized");
+ m_initialized = true;
+ m_initializer = std::move(initializer);
+
+ m_initializer->Initialize();
+ Debugger::Initialize(plugin_callback);
+ }
+}
+
+void
+SystemLifetimeManager::Terminate()
+{
+ Mutex::Locker locker(m_mutex);
+
+ if (m_initialized)
+ {
+ Debugger::Terminate();
+ m_initializer->Terminate();
+
+ m_initializer.reset();
+ m_initialized = false;
+ }
+}
Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Tue Mar 31 16:03:22 2015
@@ -110,61 +110,3 @@ ScriptInterpreter::AcquireInterpreterLoc
{
return std::unique_ptr<ScriptInterpreterLocker>(new ScriptInterpreterLocker());
}
-
-void
-ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback,
- SWIGBreakpointCallbackFunction swig_breakpoint_callback,
- SWIGWatchpointCallbackFunction swig_watchpoint_callback,
- SWIGPythonTypeScriptCallbackFunction swig_typescript_callback,
- SWIGPythonCreateSyntheticProvider swig_synthetic_script,
- SWIGPythonCreateCommandObject swig_create_cmd,
- SWIGPythonCalculateNumChildren swig_calc_children,
- SWIGPythonGetChildAtIndex swig_get_child_index,
- SWIGPythonGetIndexOfChildWithName swig_get_index_child,
- SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue ,
- SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue,
- SWIGPythonUpdateSynthProviderInstance swig_update_provider,
- SWIGPythonMightHaveChildrenSynthProviderInstance swig_mighthavechildren_provider,
- SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider,
- SWIGPythonCallCommand swig_call_command,
- SWIGPythonCallCommandObject swig_call_command_object,
- SWIGPythonCallModuleInit swig_call_module_init,
- SWIGPythonCreateOSPlugin swig_create_os_plugin,
- SWIGPythonScriptKeyword_Process swig_run_script_keyword_process,
- SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread,
- SWIGPythonScriptKeyword_Target swig_run_script_keyword_target,
- SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame,
- SWIGPythonScriptKeyword_Value swig_run_script_keyword_value,
- SWIGPython_GetDynamicSetting swig_plugin_get,
- SWIGPythonCreateScriptedThreadPlan swig_thread_plan_script,
- SWIGPythonCallThreadPlan swig_call_thread_plan)
-{
-#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback,
- swig_breakpoint_callback,
- swig_watchpoint_callback,
- swig_typescript_callback,
- swig_synthetic_script,
- swig_create_cmd,
- swig_calc_children,
- swig_get_child_index,
- swig_get_index_child,
- swig_cast_to_sbvalue ,
- swig_get_valobj_sp_from_sbvalue,
- swig_update_provider,
- swig_mighthavechildren_provider,
- swig_getvalue_provider,
- swig_call_command,
- swig_call_command_object,
- swig_call_module_init,
- swig_create_os_plugin,
- swig_run_script_keyword_process,
- swig_run_script_keyword_thread,
- swig_run_script_keyword_target,
- swig_run_script_keyword_frame,
- swig_run_script_keyword_value,
- swig_plugin_get,
- swig_thread_plan_script,
- swig_call_thread_plan);
-#endif // #ifndef LLDB_DISABLE_PYTHON
-}
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Mar 31 16:03:22 2015
@@ -48,33 +48,34 @@
using namespace lldb;
using namespace lldb_private;
+static ScriptInterpreterPython::SWIGInitCallback g_swig_init_callback = nullptr;
+static ScriptInterpreterPython::SWIGBreakpointCallbackFunction g_swig_breakpoint_callback = nullptr;
+static ScriptInterpreterPython::SWIGWatchpointCallbackFunction g_swig_watchpoint_callback = nullptr;
+static ScriptInterpreterPython::SWIGPythonTypeScriptCallbackFunction g_swig_typescript_callback = nullptr;
+static ScriptInterpreterPython::SWIGPythonCreateSyntheticProvider g_swig_synthetic_script = nullptr;
+static ScriptInterpreterPython::SWIGPythonCreateCommandObject g_swig_create_cmd = nullptr;
+static ScriptInterpreterPython::SWIGPythonCalculateNumChildren g_swig_calc_children = nullptr;
+static ScriptInterpreterPython::SWIGPythonGetChildAtIndex g_swig_get_child_index = nullptr;
+static ScriptInterpreterPython::SWIGPythonGetIndexOfChildWithName g_swig_get_index_child = nullptr;
+static ScriptInterpreterPython::SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue = nullptr;
+static ScriptInterpreterPython::SWIGPythonGetValueObjectSPFromSBValue g_swig_get_valobj_sp_from_sbvalue = nullptr;
+static ScriptInterpreterPython::SWIGPythonUpdateSynthProviderInstance g_swig_update_provider = nullptr;
+static ScriptInterpreterPython::SWIGPythonMightHaveChildrenSynthProviderInstance g_swig_mighthavechildren_provider = nullptr;
+static ScriptInterpreterPython::SWIGPythonGetValueSynthProviderInstance g_swig_getvalue_provider = nullptr;
+static ScriptInterpreterPython::SWIGPythonCallCommand g_swig_call_command = nullptr;
+static ScriptInterpreterPython::SWIGPythonCallCommandObject g_swig_call_command_object = nullptr;
+static ScriptInterpreterPython::SWIGPythonCallModuleInit g_swig_call_module_init = nullptr;
+static ScriptInterpreterPython::SWIGPythonCreateOSPlugin g_swig_create_os_plugin = nullptr;
+static ScriptInterpreterPython::SWIGPythonScriptKeyword_Process g_swig_run_script_keyword_process = nullptr;
+static ScriptInterpreterPython::SWIGPythonScriptKeyword_Thread g_swig_run_script_keyword_thread = nullptr;
+static ScriptInterpreterPython::SWIGPythonScriptKeyword_Target g_swig_run_script_keyword_target = nullptr;
+static ScriptInterpreterPython::SWIGPythonScriptKeyword_Frame g_swig_run_script_keyword_frame = nullptr;
+static ScriptInterpreterPython::SWIGPythonScriptKeyword_Value g_swig_run_script_keyword_value = nullptr;
+static ScriptInterpreterPython::SWIGPython_GetDynamicSetting g_swig_plugin_get = nullptr;
+static ScriptInterpreterPython::SWIGPythonCreateScriptedThreadPlan g_swig_thread_plan_script = nullptr;
+static ScriptInterpreterPython::SWIGPythonCallThreadPlan g_swig_call_thread_plan = nullptr;
-static ScriptInterpreter::SWIGInitCallback g_swig_init_callback = nullptr;
-static ScriptInterpreter::SWIGBreakpointCallbackFunction g_swig_breakpoint_callback = nullptr;
-static ScriptInterpreter::SWIGWatchpointCallbackFunction g_swig_watchpoint_callback = nullptr;
-static ScriptInterpreter::SWIGPythonTypeScriptCallbackFunction g_swig_typescript_callback = nullptr;
-static ScriptInterpreter::SWIGPythonCreateSyntheticProvider g_swig_synthetic_script = nullptr;
-static ScriptInterpreter::SWIGPythonCreateCommandObject g_swig_create_cmd = nullptr;
-static ScriptInterpreter::SWIGPythonCalculateNumChildren g_swig_calc_children = nullptr;
-static ScriptInterpreter::SWIGPythonGetChildAtIndex g_swig_get_child_index = nullptr;
-static ScriptInterpreter::SWIGPythonGetIndexOfChildWithName g_swig_get_index_child = nullptr;
-static ScriptInterpreter::SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue = nullptr;
-static ScriptInterpreter::SWIGPythonGetValueObjectSPFromSBValue g_swig_get_valobj_sp_from_sbvalue = nullptr;
-static ScriptInterpreter::SWIGPythonUpdateSynthProviderInstance g_swig_update_provider = nullptr;
-static ScriptInterpreter::SWIGPythonMightHaveChildrenSynthProviderInstance g_swig_mighthavechildren_provider = nullptr;
-static ScriptInterpreter::SWIGPythonGetValueSynthProviderInstance g_swig_getvalue_provider = nullptr;
-static ScriptInterpreter::SWIGPythonCallCommand g_swig_call_command = nullptr;
-static ScriptInterpreter::SWIGPythonCallCommandObject g_swig_call_command_object = nullptr;
-static ScriptInterpreter::SWIGPythonCallModuleInit g_swig_call_module_init = nullptr;
-static ScriptInterpreter::SWIGPythonCreateOSPlugin g_swig_create_os_plugin = nullptr;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Process g_swig_run_script_keyword_process = nullptr;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Thread g_swig_run_script_keyword_thread = nullptr;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Target g_swig_run_script_keyword_target = nullptr;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Frame g_swig_run_script_keyword_frame = nullptr;
-static ScriptInterpreter::SWIGPythonScriptKeyword_Value g_swig_run_script_keyword_value = nullptr;
-static ScriptInterpreter::SWIGPython_GetDynamicSetting g_swig_plugin_get = nullptr;
-static ScriptInterpreter::SWIGPythonCreateScriptedThreadPlan g_swig_thread_plan_script = nullptr;
-static ScriptInterpreter::SWIGPythonCallThreadPlan g_swig_call_thread_plan = nullptr;
+static bool g_initialized = false;
static std::string
ReadPythonBacktrace (PyObject* py_backtrace);
@@ -175,8 +176,7 @@ ScriptInterpreterPython::ScriptInterpret
m_lock_count (0),
m_command_thread_state (nullptr)
{
-
- ScriptInterpreterPython::InitializePrivate ();
+ assert(g_initialized && "ScriptInterpreterPython created but initialize has not been called!");
m_dictionary_name.append("_dict");
StreamString run_string;
@@ -189,16 +189,6 @@ ScriptInterpreterPython::ScriptInterpret
run_string.Clear();
- // Importing 'lldb' module calls SBDebugger::Initialize, which calls Debugger::Initialize, which increments a
- // global debugger ref-count; therefore we need to check the ref-count before and after importing lldb, and if the
- // ref-count increased we need to call Debugger::Terminate here to decrement the ref-count so that when the final
- // call to Debugger::Terminate is made, the ref-count has the correct value.
- //
- // Bonus question: Why doesn't the ref-count always increase? Because sometimes lldb has already been imported, in
- // which case the code inside it, including the call to SBDebugger::Initialize(), does not get executed.
-
- int old_count = Debugger::TestDebuggerRefCount();
-
run_string.Printf ("run_one_line (%s, 'import copy, keyword, os, re, sys, uuid, lldb')", m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
@@ -209,11 +199,6 @@ ScriptInterpreterPython::ScriptInterpret
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
- int new_count = Debugger::TestDebuggerRefCount();
-
- if (new_count > old_count)
- Debugger::Terminate();
-
run_string.Printf ("run_one_line (%s, 'import lldb.embedded_interpreter; from lldb.embedded_interpreter import run_python_interpreter; from lldb.embedded_interpreter import run_one_line')", m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
@@ -3029,11 +3014,7 @@ ScriptInterpreterPython::InitializeInter
void
ScriptInterpreterPython::InitializePrivate ()
{
- static int g_initialized = false;
-
- if (g_initialized)
- return;
-
+ assert(!g_initialized && "ScriptInterpreterPython::InitializePrivate() called more than once!");
g_initialized = true;
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
@@ -3057,7 +3038,6 @@ ScriptInterpreterPython::InitializePriva
}
Py_InitializeEx (0);
- // Initialize SWIG after setting up python
if (g_swig_init_callback)
g_swig_init_callback ();
@@ -3095,20 +3075,8 @@ ScriptInterpreterPython::InitializePriva
}
}
- // Importing 'lldb' module calls SBDebugger::Initialize, which calls Debugger::Initialize, which increments a
- // global debugger ref-count; therefore we need to check the ref-count before and after importing lldb, and if the
- // ref-count increased we need to call Debugger::Terminate here to decrement the ref-count so that when the final
- // call to Debugger::Terminate is made, the ref-count has the correct value.
-
- int old_count = Debugger::TestDebuggerRefCount ();
-
PyRun_SimpleString ("sys.dont_write_bytecode = 1; import lldb.embedded_interpreter; from lldb.embedded_interpreter import run_python_interpreter; from lldb.embedded_interpreter import run_one_line");
- int new_count = Debugger::TestDebuggerRefCount ();
-
- if (new_count > old_count)
- Debugger::Terminate ();
-
if (threads_already_initialized) {
if (log)
log->Printf("Releasing PyGILState. Returning to state = %slocked\n", gstate == PyGILState_UNLOCKED ? "un" : "");
Modified: lldb/trunk/tools/lldb-server/lldb-server.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-server.cpp?rev=233758&r1=233757&r2=233758&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-server.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-server.cpp Tue Mar 31 16:03:22 2015
@@ -8,11 +8,17 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/Debugger.h"
-#include "lldb/Initialization/InitializeLLDB.h"
+#include "lldb/Initialization/SystemLifetimeManager.h"
+#include "lldb/Initialization/SystemInitializerCommon.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/ManagedStatic.h"
#include <stdio.h>
#include <stdlib.h>
+static llvm::ManagedStatic<lldb_private::SystemLifetimeManager> g_debugger_lifetime;
+
static void
display_usage (const char *progname)
{
@@ -30,13 +36,13 @@ int main_platform (int argc, char *argv[
static void
initialize ()
{
- lldb_private::InitializeForLLGS(nullptr);
+ g_debugger_lifetime->Initialize(llvm::make_unique<lldb_private::SystemInitializerCommon>(), nullptr);
}
static void
terminate ()
{
- lldb_private::TerminateLLGS();
+ g_debugger_lifetime->Terminate();
}
//----------------------------------------------------------------------
More information about the lldb-commits
mailing list