lldbHost
lldbCore
lldbExpression
+ lldbInitialization
lldbInterpreter
lldbSymbol
lldbTarget
public:
- typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType) (const lldb::DebuggerSP &debugger_sp,
- const FileSpec& spec,
- Error& error);
-
static lldb::DebuggerSP
CreateInstance (lldb::LogOutputCallback log_callback = NULL, void *baton = NULL);
FindTargetWithProcess (Process *process);
static void
- InitializeForLLGS (LoadPluginCallbackType load_plugin_callback);
-
- static void
Initialize (LoadPluginCallbackType load_plugin_callback);
- static void
+ static int
Terminate ();
static void
static const char *
GetSignalAsCString (int signo);
- static void
- WillTerminate ();
-
typedef void (*ThreadLocalStorageCleanupCallback) (void *p);
static lldb::thread_key_t
--- /dev/null
+//===-- 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
typedef std::shared_ptr<lldb_private::VariableList> VariableListSP;
typedef std::shared_ptr<lldb_private::ValueObjectList> ValueObjectListSP;
typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP;
-
+
} // namespace lldb
#include "lldb/lldb-private.h"
+namespace llvm
+{
+namespace sys
+{
+class DynamicLibrary;
+}
+}
+
namespace lldb_private
{
class Platform;
class ExecutionContext;
+ typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(const lldb::DebuggerSP &debugger_sp,
+ const FileSpec &spec, Error &error);
+
//----------------------------------------------------------------------
// Every register is described in detail including its name, alternate
// name (optional), encoding, size in bytes and the default display
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();
-
-//------------------------------------------------------------------
-/// 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();
-
-//------------------------------------------------------------------
-/// Notifies any classes that lldb will be terminating soon.
-///
-/// This function will be called when the Debugger shared instance
-/// is being destructed and will give classes the ability to clean
-/// up any threads or other resources they have that they might not
-/// be able to clean up in their own destructors.
-///
-/// Internal classes that need this ability will need to add their
-/// void T::WillTerminate() method in the body of this function in
-/// lldb.cpp to ensure it will get called.
-///
-/// TODO: when we start having external plug-ins, we will need a way
-/// for plug-ins to register a WillTerminate callback.
-//------------------------------------------------------------------
-void
-WillTerminate();
-
-//------------------------------------------------------------------
-/// 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();
-
const char *
GetVersion ();
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 */; };
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 */; };
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>"; };
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>"; };
94CB255616B0683B0059775D /* DataFormatters */,
26BC7DBE10F1B78200F91463 /* Expression */,
26BC7DD010F1B7C100F91463 /* Host */,
+ 3F8169261ABB73C1001DA9DF /* Initialization */,
26BC7DDF10F1B7E200F91463 /* Interpreter */,
260C897110F57C5600BB2B04 /* Plugins */,
26BC7C4B10F1B6C100F91463 /* Symbol */,
path = "POSIX-DYLD";
sourceTree = "<group>";
};
+ 3F8169261ABB73C1001DA9DF /* Initialization */ = {
+ isa = PBXGroup;
+ children = (
+ 3F8169291ABB73E6001DA9DF /* InitializeLLDB.h */,
+ 3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */,
+ );
+ name = Initialization;
+ sourceTree = "<group>";
+ };
3FDFDDC4199D37BE009756A7 /* posix */ = {
isa = PBXGroup;
children = (
94CB257216B0A4270059775D /* TypeSynthetic.cpp in Sources */,
94CB257416B1D3880059775D /* FormatCache.cpp in Sources */,
A36FF33C17D8E94600244D40 /* OptionParser.cpp in Sources */,
+ 3F8169281ABB73D9001DA9DF /* InitializeLLDB.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "lldb/API/SBTypeSummary.h"
#include "lldb/API/SBTypeSynthetic.h"
-
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Initialization/InitializeLLDB.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
SBCommandInterpreter::InitializeSWIG ();
- Debugger::Initialize(LoadPlugin);
+ lldb_private::Initialize(LoadPlugin);
}
void
SBDebugger::Terminate ()
{
- Debugger::Terminate();
+ lldb_private::Terminate();
}
void
add_subdirectory(DataFormatters)
add_subdirectory(Expression)
add_subdirectory(Host)
+add_subdirectory(Initialization)
add_subdirectory(Interpreter)
add_subdirectory(Plugins)
add_subdirectory(Symbol)
add_subdirectory(Target)
add_subdirectory(Utility)
-# Build API last, since liblldb needs to link against every other target
+# Build API last. Since liblldb needs to link against every other target, it needs
+# those targets to have already been created.
add_subdirectory(API)
# Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as
#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"
ePropertyEscapeNonPrintables
};
-Debugger::LoadPluginCallbackType Debugger::g_load_plugin_callback = NULL;
+LoadPluginCallbackType Debugger::g_load_plugin_callback = NULL;
Error
Debugger::SetPropertyValue (const ExecutionContext *exe_ctx,
return g_shared_debugger_refcount;
}
-static bool lldb_initialized_for_llgs = false;
-void
-Debugger::InitializeForLLGS (LoadPluginCallbackType load_plugin_callback)
-{
- lldb_initialized_for_llgs = true;
- g_shared_debugger_refcount++;
- g_load_plugin_callback = load_plugin_callback;
- lldb_private::InitializeForLLGS();
-}
-
static bool lldb_initialized = true;
void
-Debugger::Initialize (LoadPluginCallbackType load_plugin_callback)
+Debugger::Initialize(LoadPluginCallbackType load_plugin_callback)
{
lldb_initialized = true;
g_shared_debugger_refcount++;
g_load_plugin_callback = load_plugin_callback;
- lldb_private::Initialize();
}
-void
+int
Debugger::Terminate ()
{
if (g_shared_debugger_refcount > 0)
g_shared_debugger_refcount--;
if (g_shared_debugger_refcount == 0)
{
- lldb_private::WillTerminate();
- if (lldb_initialized_for_llgs) {
- lldb_initialized_for_llgs = false;
- lldb_private::TerminateLLGS();
- }
- if (lldb_initialized) {
- lldb_initialized = false;
- lldb_private::Terminate();
- }
-
// Clear our master list of debugger objects
Mutex::Locker locker (GetDebuggerListMutex ());
GetDebuggerList().clear();
}
}
+ return g_shared_debugger_refcount;
}
void
#endif
-void
-Host::WillTerminate ()
-{
-}
-
#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) && !defined (__linux__) // see macosx/Host.mm
size_t
--- /dev/null
+add_lldb_library(lldbInitialization
+ InitializeLLDB.cpp
+ )
--- /dev/null
+//===-- 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);
+
+ ProcessGDBRemoteLog::Initialize();
+
+ // Initialize plug-ins
+ ObjectContainerBSDArchive::Initialize();
+ ObjectFileELF::Initialize();
+ ObjectFilePECOFF::Initialize();
+ DynamicLoaderPOSIXDYLD::Initialize();
+ PlatformFreeBSD::Initialize();
+ PlatformLinux::Initialize();
+ PlatformWindows::Initialize();
+ PlatformKalimba::Initialize();
+ 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
+ //----------------------------------------------------------------------
+ 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
+ //----------------------------------------------------------------------
+ PlatformRemoteGDBServer::Initialize();
+
+ 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();
+ PlatformLinux::Terminate();
+ PlatformWindows::Terminate();
+ PlatformKalimba::Terminate();
+ 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__)
+ ProcessLinux::Terminate();
+#endif
+
+#if defined(__FreeBSD__)
+ ProcessFreeBSD::Terminate();
+#endif
+ Debugger::SettingsTerminate();
+
+ PlatformRemoteGDBServer::Terminate();
+ 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();
+}
--- /dev/null
+##===- source/Initialize/Makefile -------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../..
+LIBRARYNAME := lldbInitialize
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ..
-PARALLEL_DIRS := API Breakpoint Commands Core DataFormatters Expression Host Interpreter Plugins Symbol Target Utility
+PARALLEL_DIRS := API Initialization Breakpoint Commands Core DataFormatters Expression Host Interpreter Plugins Symbol Target Utility
LIBRARYNAME := lldbInitAndLog
BUILD_ARCHIVE = 1
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
-
#include "lldb/lldb-private.h"
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/Mutex.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/TargetSelect.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/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
-#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
-#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
-#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
-#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
-#include "Plugins/Platform/Android/PlatformAndroid.h"
-#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
-#include "Plugins/Platform/Linux/PlatformLinux.h"
-#include "Plugins/Platform/Windows/PlatformWindows.h"
-#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
-#include "Plugins/Process/elf-core/ProcessElfCore.h"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
-#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
-#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
-#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
-
-#ifndef LLDB_DISABLE_PYTHON
-#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
-#endif
-
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
-#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
-#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
-#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
-#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.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 (__linux__)
-#include "Plugins/Process/Linux/ProcessLinux.h"
-#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
-#endif
-
-#if defined (_WIN32)
-#include "lldb/Host/windows/windows.h"
-#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
-#include "Plugins/Process/Windows/ProcessWindows.h"
-#endif
-
-#if defined (__FreeBSD__)
-#include "Plugins/Process/POSIX/ProcessPOSIX.h"
-#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
-#endif
-
-#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
-#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
-#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
-#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
using namespace lldb;
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;
-void
-lldb_private::InitializeForLLGS ()
-{
- // Make sure we initialize only once
- static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
-
- Mutex::Locker locker(g_inited_mutex);
- if (!g_inited_for_llgs)
- {
- 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);
-
- ProcessGDBRemoteLog::Initialize();
-
- // Initialize plug-ins
- ObjectContainerBSDArchive::Initialize();
- ObjectFileELF::Initialize();
- ObjectFilePECOFF::Initialize();
- DynamicLoaderPOSIXDYLD::Initialize();
- PlatformFreeBSD::Initialize();
- PlatformLinux::Initialize();
- PlatformWindows::Initialize();
- PlatformKalimba::Initialize();
- 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;
-void
-lldb_private::Initialize ()
-{
- // Make sure we initialize only once
- static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
-
- InitializeForLLGS();
- Mutex::Locker locker(g_inited_mutex);
- if (!g_inited)
- {
- g_inited = true;
-
- // 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
- //----------------------------------------------------------------------
- PlatformRemoteGDBServer::Initialize();
-
- 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
-lldb_private::WillTerminate()
-{
- Host::WillTerminate();
-}
-
-void
-lldb_private::TerminateLLGS ()
-{
- if (g_inited_for_llgs)
- {
- g_inited_for_llgs = false;
-
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- ObjectContainerBSDArchive::Terminate();
- ObjectFileELF::Terminate();
- ObjectFilePECOFF::Terminate ();
- DynamicLoaderPOSIXDYLD::Terminate ();
- PlatformFreeBSD::Terminate();
- PlatformLinux::Terminate();
- PlatformWindows::Terminate();
- PlatformKalimba::Terminate();
- 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();
- }
-}
-
-void
-lldb_private::Terminate ()
-{
- if (g_inited)
- {
- 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__)
- ProcessLinux::Terminate();
-#endif
-
-#if defined (__FreeBSD__)
- ProcessFreeBSD::Terminate();
-#endif
- Debugger::SettingsTerminate ();
-
- PlatformRemoteGDBServer::Terminate();
- ProcessGDBRemote::Terminate();
- DynamicLoaderStatic::Terminate();
-
- TerminateLLGS();
- }
-}
-
#if defined (__APPLE__)
extern "C" const unsigned char liblldb_coreVersionString[];
#else
//===----------------------------------------------------------------------===//
#include "lldb/Core/Debugger.h"
+#include "lldb/Initialization/InitializeLLDB.h"
#include <stdio.h>
#include <stdlib.h>
static void
initialize ()
{
- lldb_private::Debugger::InitializeForLLGS(NULL);
+ lldb_private::InitializeForLLGS(nullptr);
}
static void
terminate ()
{
- lldb_private::Debugger::Terminate();
+ lldb_private::TerminateLLGS();
}
//----------------------------------------------------------------------