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" |
Stephen Wilson | 015eb23 | 2011-03-13 00:00:32 +0000 | [diff] [blame] | 13 | #include "lldb/Core/Debugger.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 14 | #include "lldb/Core/Log.h" |
Greg Clayton | 52fd984 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 15 | #include "lldb/Core/PluginManager.h" |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 16 | #include "lldb/Core/RegularExpression.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/Core/Timer.h" |
| 18 | #include "lldb/Host/Host.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 19 | #include "lldb/Host/Mutex.h" |
Greg Clayton | e01879a | 2010-12-16 21:36:30 +0000 | [diff] [blame] | 20 | #include "lldb/Target/Target.h" |
| 21 | #include "lldb/Target/Thread.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 22 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/StringRef.h" |
| 24 | |
Peter Collingbourne | b7f5945 | 2011-05-19 18:32:34 +0000 | [diff] [blame] | 25 | #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" |
| 26 | #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" |
Peter Collingbourne | aa9719a | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 27 | #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 28 | #include "Plugins/Disassembler/llvm/DisassemblerLLVM.h" |
Sean Callanan | 32a56ec | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 29 | #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" |
Caroline Tice | 080bf61 | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 30 | #include "Plugins/Instruction/ARM/EmulateInstructionARM.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 31 | #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" |
| 32 | #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h" |
| 33 | #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" |
| 34 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" |
| 35 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" |
| 36 | #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" |
Greg Clayton | 9a1941b | 2011-04-25 21:07:40 +0000 | [diff] [blame] | 37 | #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" |
Greg Clayton | f6e287a | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 38 | #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" |
Greg Clayton | e9f4982 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 39 | #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" |
Greg Clayton | 1fb32d1 | 2012-02-27 19:00:34 +0000 | [diff] [blame] | 40 | #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h" |
Greg Clayton | a605c64 | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 41 | #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" |
| 42 | #include "Plugins/Platform/Linux/PlatformLinux.h" |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 43 | #if defined (__APPLE__) |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 44 | #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" |
Greg Clayton | 17f3d05 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 45 | #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" |
| 46 | #include "Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h" |
Jim Ingham | 642036f | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 47 | #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" |
Jim Ingham | 2eac2b9 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 48 | #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" |
| 49 | #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 50 | #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" |
| 51 | #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" |
Greg Clayton | 8d2ea28 | 2011-07-17 20:36:25 +0000 | [diff] [blame] | 52 | #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 53 | #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 54 | #include "Plugins/Platform/MacOSX/PlatformMacOSX.h" |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 55 | #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" |
Greg Clayton | f96c883 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 56 | #include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 57 | #endif |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 58 | |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 59 | #include "Plugins/Process/mach-core/ProcessMachCore.h" |
| 60 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 61 | #if defined (__linux__) |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 62 | #include "Plugins/Process/Linux/ProcessLinux.h" |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 63 | #endif |
| 64 | |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 65 | #if defined (__FreeBSD__) |
Johnny Chen | 78dae82 | 2012-04-14 00:54:42 +0000 | [diff] [blame^] | 66 | #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" |
Johnny Chen | 7e99647 | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 67 | #include "Plugins/Process/POSIX/ProcessPOSIX.h" |
| 68 | #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 69 | #endif |
| 70 | |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 71 | #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" |
Greg Clayton | bd321c5 | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 72 | #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" |
| 73 | |
Greg Clayton | adb909b | 2010-12-16 21:33:41 +0000 | [diff] [blame] | 74 | using namespace lldb; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 75 | using namespace lldb_private; |
| 76 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 77 | void |
| 78 | lldb_private::Initialize () |
| 79 | { |
| 80 | // Make sure we inialize only once |
Caroline Tice | 0aa2e55 | 2011-01-14 00:29:16 +0000 | [diff] [blame] | 81 | static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 82 | static bool g_inited = false; |
| 83 | |
| 84 | Mutex::Locker locker(g_inited_mutex); |
| 85 | if (!g_inited) |
| 86 | { |
| 87 | g_inited = true; |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 88 | Log::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 89 | Timer::Initialize (); |
| 90 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 91 | |
Peter Collingbourne | b7f5945 | 2011-05-19 18:32:34 +0000 | [diff] [blame] | 92 | ABIMacOSX_i386::Initialize(); |
| 93 | ABIMacOSX_arm::Initialize(); |
Peter Collingbourne | aa9719a | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 94 | ABISysV_x86_64::Initialize(); |
Sean Callanan | 32a56ec | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 95 | DisassemblerLLVMC::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 96 | DisassemblerLLVM::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 97 | ObjectContainerBSDArchive::Initialize(); |
| 98 | ObjectFileELF::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 99 | SymbolFileDWARF::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 100 | SymbolFileSymtab::Initialize(); |
Greg Clayton | f6e287a | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 101 | UnwindAssemblyInstEmulation::Initialize(); |
Greg Clayton | 888a733 | 2011-04-26 04:39:08 +0000 | [diff] [blame] | 102 | UnwindAssembly_x86::Initialize(); |
Caroline Tice | 080bf61 | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 103 | EmulateInstructionARM::Initialize (); |
Greg Clayton | e9f4982 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 104 | ObjectFilePECOFF::Initialize (); |
Bill Wendling | 0fd911c | 2012-04-05 17:38:07 +0000 | [diff] [blame] | 105 | DynamicLoaderPOSIXDYLD::Initialize (); |
Greg Clayton | a605c64 | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 106 | PlatformFreeBSD::Initialize(); |
| 107 | PlatformLinux::Initialize(); |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 108 | #if defined (__APPLE__) |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 109 | //---------------------------------------------------------------------- |
| 110 | // Apple/Darwin hosted plugins |
| 111 | //---------------------------------------------------------------------- |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 112 | DynamicLoaderMacOSXDYLD::Initialize(); |
Greg Clayton | 17f3d05 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 113 | DynamicLoaderDarwinKernel::Initialize(); |
| 114 | OperatingSystemDarwinKernel::Initialize(); |
Stephen Wilson | be1acb2 | 2011-01-12 04:22:09 +0000 | [diff] [blame] | 115 | SymbolFileDWARFDebugMap::Initialize(); |
Jim Ingham | 642036f | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 116 | ItaniumABILanguageRuntime::Initialize(); |
| 117 | AppleObjCRuntimeV2::Initialize(); |
Jim Ingham | 2eac2b9 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 118 | AppleObjCRuntimeV1::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 119 | ObjectContainerUniversalMachO::Initialize(); |
| 120 | ObjectFileMachO::Initialize(); |
Greg Clayton | 8d2ea28 | 2011-07-17 20:36:25 +0000 | [diff] [blame] | 121 | ProcessKDP::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 122 | ProcessGDBRemote::Initialize(); |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 123 | ProcessMachCore::Initialize(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 124 | SymbolVendorMacOSX::Initialize(); |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 125 | PlatformRemoteiOS::Initialize(); |
Greg Clayton | b1db658 | 2012-03-20 18:34:04 +0000 | [diff] [blame] | 126 | PlatformMacOSX::Initialize(); |
Greg Clayton | f96c883 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 127 | PlatformiOSSimulator::Initialize(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 128 | #endif |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 129 | #if defined (__linux__) |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 130 | //---------------------------------------------------------------------- |
| 131 | // Linux hosted plugins |
| 132 | //---------------------------------------------------------------------- |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 133 | ProcessLinux::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 134 | #endif |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 135 | #if defined (__FreeBSD__) |
Johnny Chen | 7e99647 | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 136 | ProcessFreeBSD::Initialize(); |
Johnny Chen | 78dae82 | 2012-04-14 00:54:42 +0000 | [diff] [blame^] | 137 | ProcessGDBRemote::Initialize(); |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 138 | #endif |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 139 | //---------------------------------------------------------------------- |
| 140 | // Platform agnostic plugins |
| 141 | //---------------------------------------------------------------------- |
| 142 | PlatformRemoteGDBServer::Initialize (); |
Greg Clayton | bd321c5 | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 143 | DynamicLoaderStatic::Initialize(); |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 144 | |
Greg Clayton | 52fd984 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 145 | // Scan for any system or user LLDB plug-ins |
| 146 | PluginManager::Initialize(); |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 147 | |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 148 | // The process settings need to know about installed plug-ins, so the Settings must be initialized |
| 149 | // AFTER PluginManager::Initialize is called. |
| 150 | |
| 151 | Debugger::SettingsInitialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 152 | } |
| 153 | } |
| 154 | |
| 155 | void |
| 156 | lldb_private::WillTerminate() |
| 157 | { |
| 158 | Host::WillTerminate(); |
| 159 | } |
| 160 | |
| 161 | void |
| 162 | lldb_private::Terminate () |
| 163 | { |
| 164 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
Greg Clayton | 52fd984 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 165 | |
| 166 | // Terminate and unload and loaded system or user LLDB plug-ins |
| 167 | PluginManager::Terminate(); |
| 168 | |
Peter Collingbourne | b7f5945 | 2011-05-19 18:32:34 +0000 | [diff] [blame] | 169 | ABIMacOSX_i386::Terminate(); |
| 170 | ABIMacOSX_arm::Terminate(); |
Peter Collingbourne | aa9719a | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 171 | ABISysV_x86_64::Terminate(); |
Sean Callanan | 32a56ec | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 172 | DisassemblerLLVMC::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 173 | DisassemblerLLVM::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 174 | ObjectContainerBSDArchive::Terminate(); |
| 175 | ObjectFileELF::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 176 | SymbolFileDWARF::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 177 | SymbolFileSymtab::Terminate(); |
Greg Clayton | f6e287a | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 178 | UnwindAssembly_x86::Terminate(); |
| 179 | UnwindAssemblyInstEmulation::Terminate(); |
Caroline Tice | 080bf61 | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 180 | EmulateInstructionARM::Terminate (); |
Greg Clayton | e9f4982 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 181 | ObjectFilePECOFF::Terminate (); |
Bill Wendling | 0fd911c | 2012-04-05 17:38:07 +0000 | [diff] [blame] | 182 | DynamicLoaderPOSIXDYLD::Terminate (); |
Greg Clayton | a605c64 | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 183 | PlatformFreeBSD::Terminate(); |
| 184 | PlatformLinux::Terminate(); |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 185 | #if defined (__APPLE__) |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 186 | DynamicLoaderMacOSXDYLD::Terminate(); |
Greg Clayton | 17f3d05 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 187 | DynamicLoaderDarwinKernel::Terminate(); |
| 188 | OperatingSystemDarwinKernel::Terminate(); |
Stephen Wilson | be1acb2 | 2011-01-12 04:22:09 +0000 | [diff] [blame] | 189 | SymbolFileDWARFDebugMap::Terminate(); |
Jim Ingham | 2eac2b9 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 190 | ItaniumABILanguageRuntime::Terminate(); |
| 191 | AppleObjCRuntimeV2::Terminate(); |
| 192 | AppleObjCRuntimeV1::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 193 | ObjectContainerUniversalMachO::Terminate(); |
| 194 | ObjectFileMachO::Terminate(); |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 195 | ProcessMachCore::Terminate(); |
Greg Clayton | 8d2ea28 | 2011-07-17 20:36:25 +0000 | [diff] [blame] | 196 | ProcessKDP::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 197 | ProcessGDBRemote::Terminate(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 198 | SymbolVendorMacOSX::Terminate(); |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 199 | PlatformMacOSX::Terminate(); |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 200 | PlatformRemoteiOS::Terminate(); |
Greg Clayton | f96c883 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 201 | PlatformiOSSimulator::Terminate(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 202 | #endif |
| 203 | |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 204 | Debugger::SettingsTerminate (); |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 205 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 206 | #if defined (__linux__) |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 207 | ProcessLinux::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 208 | #endif |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 209 | |
| 210 | #if defined (__FreeBSD__) |
Johnny Chen | 7e99647 | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 211 | ProcessFreeBSD::Terminate(); |
Johnny Chen | 78dae82 | 2012-04-14 00:54:42 +0000 | [diff] [blame^] | 212 | ProcessGDBRemote::Terminate(); |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 213 | #endif |
Greg Clayton | bd321c5 | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 214 | |
| 215 | DynamicLoaderStatic::Terminate(); |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 216 | |
| 217 | Log::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Greg Clayton | e86cbb9 | 2011-03-22 01:14:58 +0000 | [diff] [blame] | 220 | extern "C" const double liblldb_coreVersionNumber; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 221 | const char * |
| 222 | lldb_private::GetVersion () |
| 223 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 224 | static char g_version_string[32]; |
| 225 | if (g_version_string[0] == '\0') |
Greg Clayton | e86cbb9 | 2011-03-22 01:14:58 +0000 | [diff] [blame] | 226 | ::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", liblldb_coreVersionNumber); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 227 | |
| 228 | return g_version_string; |
| 229 | } |
| 230 | |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 231 | const char * |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 232 | lldb_private::GetVoteAsCString (Vote vote) |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 233 | { |
Greg Clayton | f04d661 | 2010-09-03 22:45:01 +0000 | [diff] [blame] | 234 | switch (vote) |
| 235 | { |
| 236 | case eVoteNo: return "no"; |
| 237 | case eVoteNoOpinion: return "no opinion"; |
| 238 | case eVoteYes: return "yes"; |
| 239 | default: |
| 240 | break; |
| 241 | } |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 242 | return "invalid"; |
| 243 | } |
| 244 | |
Greg Clayton | 3fed8b9 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 245 | |
| 246 | const char * |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 247 | lldb_private::GetSectionTypeAsCString (SectionType sect_type) |
Greg Clayton | 3fed8b9 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 248 | { |
| 249 | switch (sect_type) |
| 250 | { |
| 251 | case eSectionTypeInvalid: return "invalid"; |
| 252 | case eSectionTypeCode: return "code"; |
| 253 | case eSectionTypeContainer: return "container"; |
| 254 | case eSectionTypeData: return "data"; |
| 255 | case eSectionTypeDataCString: return "data-cstr"; |
| 256 | case eSectionTypeDataCStringPointers: return "data-cstr-ptr"; |
| 257 | case eSectionTypeDataSymbolAddress: return "data-symbol-addr"; |
| 258 | case eSectionTypeData4: return "data-4-byte"; |
| 259 | case eSectionTypeData8: return "data-8-byte"; |
| 260 | case eSectionTypeData16: return "data-16-byte"; |
| 261 | case eSectionTypeDataPointers: return "data-ptrs"; |
| 262 | case eSectionTypeDebug: return "debug"; |
| 263 | case eSectionTypeZeroFill: return "zero-fill"; |
| 264 | case eSectionTypeDataObjCMessageRefs: return "objc-message-refs"; |
| 265 | case eSectionTypeDataObjCCFStrings: return "objc-cfstrings"; |
| 266 | case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev"; |
| 267 | case eSectionTypeDWARFDebugAranges: return "dwarf-aranges"; |
| 268 | case eSectionTypeDWARFDebugFrame: return "dwarf-frame"; |
| 269 | case eSectionTypeDWARFDebugInfo: return "dwarf-info"; |
| 270 | case eSectionTypeDWARFDebugLine: return "dwarf-line"; |
| 271 | case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; |
| 272 | case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; |
| 273 | case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames"; |
| 274 | case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes"; |
| 275 | case eSectionTypeDWARFDebugRanges: return "dwarf-ranges"; |
| 276 | case eSectionTypeDWARFDebugStr: return "dwarf-str"; |
Greg Clayton | f6e3de2 | 2011-09-28 17:06:40 +0000 | [diff] [blame] | 277 | case eSectionTypeDWARFAppleNames: return "apple-names"; |
| 278 | case eSectionTypeDWARFAppleTypes: return "apple-types"; |
Greg Clayton | 00db215 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 279 | case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces"; |
Greg Clayton | 24a6bd9 | 2011-10-27 17:55:14 +0000 | [diff] [blame] | 280 | case eSectionTypeDWARFAppleObjC: return "apple-objc"; |
Greg Clayton | 3fed8b9 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 281 | case eSectionTypeEHFrame: return "eh-frame"; |
| 282 | case eSectionTypeOther: return "regular"; |
| 283 | } |
| 284 | return "unknown"; |
| 285 | |
| 286 | } |
| 287 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 288 | bool |
| 289 | lldb_private::NameMatches (const char *name, |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 290 | NameMatchType match_type, |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 291 | const char *match) |
| 292 | { |
| 293 | if (match_type == eNameMatchIgnore) |
| 294 | return true; |
| 295 | |
| 296 | if (name == match) |
| 297 | return true; |
| 298 | |
| 299 | if (name && match) |
| 300 | { |
| 301 | llvm::StringRef name_sref(name); |
| 302 | llvm::StringRef match_sref(match); |
| 303 | switch (match_type) |
| 304 | { |
| 305 | case eNameMatchIgnore: |
| 306 | return true; |
| 307 | case eNameMatchEquals: return name_sref == match_sref; |
| 308 | case eNameMatchContains: return name_sref.find (match_sref) != llvm::StringRef::npos; |
| 309 | case eNameMatchStartsWith: return name_sref.startswith (match_sref); |
| 310 | case eNameMatchEndsWith: return name_sref.endswith (match_sref); |
| 311 | case eNameMatchRegularExpression: |
| 312 | { |
| 313 | RegularExpression regex (match); |
| 314 | return regex.Execute (name); |
| 315 | } |
| 316 | break; |
| 317 | default: |
| 318 | assert (!"unhandled NameMatchType in lldb_private::NameMatches()"); |
| 319 | break; |
| 320 | } |
| 321 | } |
| 322 | return false; |
| 323 | } |