Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- lldb.cpp ------------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/lldb-private.h" |
| 11 | #include "lldb/lldb-private-log.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 12 | #include "lldb/Core/ArchSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 13 | #include "lldb/Core/Log.h" |
| 14 | #include "lldb/Core/Timer.h" |
| 15 | #include "lldb/Host/Host.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 16 | #include "lldb/Host/Mutex.h" |
| 17 | |
| 18 | #include "Plugins/Disassembler/llvm/DisassemblerLLVM.h" |
| 19 | #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" |
| 20 | #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h" |
| 21 | #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" |
Greg Clayton | 596ba27 | 2010-07-07 21:52:01 +0000 | [diff] [blame] | 22 | #include "Plugins/ObjectFile/ELF/ObjectFileELF64.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 23 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" |
| 24 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" |
| 25 | #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" |
| 26 | #ifdef __APPLE__ |
| 27 | #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" |
| 28 | #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" |
| 29 | #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" |
| 30 | #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" |
| 31 | #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" |
| 32 | #include "Plugins/Process/MacOSX-User/source/ProcessMacOSX.h" |
| 33 | #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" |
| 34 | #endif |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | |
| 36 | using namespace lldb_private; |
| 37 | |
| 38 | |
| 39 | void |
| 40 | lldb_private::Initialize () |
| 41 | { |
| 42 | // Make sure we inialize only once |
| 43 | static Mutex g_inited_mutex(Mutex::eMutexTypeNormal); |
| 44 | static bool g_inited = false; |
| 45 | |
| 46 | Mutex::Locker locker(g_inited_mutex); |
| 47 | if (!g_inited) |
| 48 | { |
| 49 | g_inited = true; |
| 50 | Timer::Initialize (); |
| 51 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
| 52 | |
| 53 | Log::Callbacks log_callbacks = { DisableLog, EnableLog, ListLogCategories }; |
| 54 | |
| 55 | Log::RegisterLogChannel ("lldb", log_callbacks); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | DisassemblerLLVM::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 57 | ObjectContainerBSDArchive::Initialize(); |
| 58 | ObjectFileELF::Initialize(); |
Greg Clayton | 596ba27 | 2010-07-07 21:52:01 +0000 | [diff] [blame] | 59 | ObjectFileELF64::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 60 | SymbolVendorMacOSX::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 61 | SymbolFileDWARF::Initialize(); |
| 62 | SymbolFileDWARFDebugMap::Initialize(); |
| 63 | SymbolFileSymtab::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 64 | #ifdef __APPLE__ |
| 65 | ABIMacOSX_i386::Initialize(); |
| 66 | ABISysV_x86_64::Initialize(); |
| 67 | DynamicLoaderMacOSXDYLD::Initialize(); |
| 68 | ObjectContainerUniversalMachO::Initialize(); |
| 69 | ObjectFileMachO::Initialize(); |
| 70 | ProcessGDBRemote::Initialize(); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame^] | 71 | // ProcessMacOSX::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 72 | #endif |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | |
| 76 | void |
| 77 | lldb_private::WillTerminate() |
| 78 | { |
| 79 | Host::WillTerminate(); |
| 80 | } |
| 81 | |
| 82 | void |
| 83 | lldb_private::Terminate () |
| 84 | { |
| 85 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
| 86 | DisassemblerLLVM::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 87 | ObjectContainerBSDArchive::Terminate(); |
| 88 | ObjectFileELF::Terminate(); |
Greg Clayton | 596ba27 | 2010-07-07 21:52:01 +0000 | [diff] [blame] | 89 | ObjectFileELF64::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 90 | SymbolVendorMacOSX::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 91 | SymbolFileDWARF::Terminate(); |
| 92 | SymbolFileDWARFDebugMap::Terminate(); |
| 93 | SymbolFileSymtab::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 94 | #ifdef __APPLE__ |
| 95 | DynamicLoaderMacOSXDYLD::Terminate(); |
| 96 | ObjectContainerUniversalMachO::Terminate(); |
| 97 | ObjectFileMachO::Terminate(); |
| 98 | ProcessGDBRemote::Terminate(); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame^] | 99 | // ProcessMacOSX::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 100 | #endif |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Benjamin Kramer | c4e0752 | 2010-07-07 09:33:41 +0000 | [diff] [blame] | 103 | extern "C" const double LLDBVersionNumber; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | const char * |
| 105 | lldb_private::GetVersion () |
| 106 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 107 | static char g_version_string[32]; |
| 108 | if (g_version_string[0] == '\0') |
| 109 | ::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", LLDBVersionNumber); |
| 110 | |
| 111 | return g_version_string; |
| 112 | } |
| 113 | |
| 114 | ArchSpec & |
| 115 | lldb_private::GetDefaultArchitecture () |
| 116 | { |
| 117 | static ArchSpec g_default_arch; |
| 118 | return g_default_arch; |
| 119 | } |