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