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" |
| 12 | #include "lldb/Core/Log.h" |
| 13 | #include "lldb/Core/Timer.h" |
| 14 | #include "lldb/Host/Host.h" |
| 15 | #include "ABIMacOSX_i386.h" |
| 16 | #include "ABISysV_x86_64.h" |
| 17 | #include "DisassemblerLLVM.h" |
| 18 | #include "DynamicLoaderMacOSXDYLD.h" |
| 19 | #include "ObjectContainerBSDArchive.h" |
| 20 | #include "ObjectContainerUniversalMachO.h" |
| 21 | #include "ObjectFileELF.h" |
| 22 | #include "ObjectFileMachO.h" |
| 23 | #include "ProcessMacOSX.h" |
| 24 | #include "ProcessGDBRemote.h" |
| 25 | #include "SymbolFileDWARF.h" |
| 26 | #include "SymbolFileDWARFDebugMap.h" |
| 27 | #include "SymbolFileSymtab.h" |
| 28 | #include "SymbolVendorMacOSX.h" |
| 29 | |
| 30 | using namespace lldb_private; |
| 31 | |
| 32 | |
| 33 | void |
| 34 | lldb_private::Initialize () |
| 35 | { |
| 36 | // Make sure we inialize only once |
| 37 | static Mutex g_inited_mutex(Mutex::eMutexTypeNormal); |
| 38 | static bool g_inited = false; |
| 39 | |
| 40 | Mutex::Locker locker(g_inited_mutex); |
| 41 | if (!g_inited) |
| 42 | { |
| 43 | g_inited = true; |
| 44 | Timer::Initialize (); |
| 45 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
| 46 | |
| 47 | Log::Callbacks log_callbacks = { DisableLog, EnableLog, ListLogCategories }; |
| 48 | |
| 49 | Log::RegisterLogChannel ("lldb", log_callbacks); |
| 50 | ABIMacOSX_i386::Initialize(); |
| 51 | ABISysV_x86_64::Initialize(); |
| 52 | DisassemblerLLVM::Initialize(); |
| 53 | DynamicLoaderMacOSXDYLD::Initialize(); |
| 54 | ObjectContainerUniversalMachO::Initialize(); |
| 55 | ObjectContainerBSDArchive::Initialize(); |
| 56 | ObjectFileELF::Initialize(); |
| 57 | ObjectFileMachO::Initialize(); |
| 58 | ProcessGDBRemote::Initialize(); |
| 59 | ProcessMacOSX::Initialize(); |
| 60 | SymbolFileDWARF::Initialize(); |
| 61 | SymbolFileDWARFDebugMap::Initialize(); |
| 62 | SymbolFileSymtab::Initialize(); |
| 63 | SymbolVendorMacOSX::Initialize(); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | lldb_private::WillTerminate() |
| 69 | { |
| 70 | Host::WillTerminate(); |
| 71 | } |
| 72 | |
| 73 | void |
| 74 | lldb_private::Terminate () |
| 75 | { |
| 76 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
| 77 | DisassemblerLLVM::Terminate(); |
| 78 | DynamicLoaderMacOSXDYLD::Terminate(); |
| 79 | ObjectContainerUniversalMachO::Terminate(); |
| 80 | ObjectContainerBSDArchive::Terminate(); |
| 81 | ObjectFileELF::Terminate(); |
| 82 | ObjectFileMachO::Terminate(); |
| 83 | ProcessGDBRemote::Terminate(); |
| 84 | ProcessMacOSX::Terminate(); |
| 85 | SymbolFileDWARF::Terminate(); |
| 86 | SymbolFileDWARFDebugMap::Terminate(); |
| 87 | SymbolFileSymtab::Terminate(); |
| 88 | SymbolVendorMacOSX::Terminate(); |
| 89 | } |
| 90 | |
| 91 | const char * |
| 92 | lldb_private::GetVersion () |
| 93 | { |
| 94 | extern const double LLDBVersionNumber; |
| 95 | static char g_version_string[32]; |
| 96 | if (g_version_string[0] == '\0') |
| 97 | ::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", LLDBVersionNumber); |
| 98 | |
| 99 | return g_version_string; |
| 100 | } |
| 101 | |
| 102 | ArchSpec & |
| 103 | lldb_private::GetDefaultArchitecture () |
| 104 | { |
| 105 | static ArchSpec g_default_arch; |
| 106 | return g_default_arch; |
| 107 | } |