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" |
Sean Callanan | 32a56ec | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 30 | #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" |
Caroline Tice | 080bf61 | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 31 | #include "Plugins/Instruction/ARM/EmulateInstructionARM.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 32 | #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" |
Michael Sartain | a807cee | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 33 | #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 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" |
Andrew Kaylor | b090668 | 2012-12-14 21:03:37 +0000 | [diff] [blame] | 45 | #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" |
Greg Clayton | d815ded | 2012-08-23 21:17:11 +0000 | [diff] [blame] | 46 | #ifndef LLDB_DISABLE_PYTHON |
| 47 | #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" |
| 48 | #endif |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 49 | #if defined (__APPLE__) |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 50 | #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" |
Greg Clayton | 17f3d05 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 51 | #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" |
Jim Ingham | 2eac2b9 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 52 | #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" |
| 53 | #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 54 | #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" |
| 55 | #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" |
Greg Clayton | 8d2ea28 | 2011-07-17 20:36:25 +0000 | [diff] [blame] | 56 | #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 57 | #include "Plugins/Platform/MacOSX/PlatformMacOSX.h" |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 58 | #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" |
Jason Molenda | e369aed | 2013-04-05 01:03:25 +0000 | [diff] [blame] | 59 | #include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h" |
Greg Clayton | f96c883 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 60 | #include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 61 | #endif |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 62 | |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 63 | #include "Plugins/Process/mach-core/ProcessMachCore.h" |
| 64 | |
Ashok Thirumurthi | f6f5269 | 2013-07-17 16:06:12 +0000 | [diff] [blame] | 65 | #if defined(__linux__) or defined(__FreeBSD__) |
| 66 | #include "Plugins/Process/elf-core/ProcessElfCore.h" |
| 67 | #endif |
| 68 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 69 | #if defined (__linux__) |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 70 | #include "Plugins/Process/Linux/ProcessLinux.h" |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 71 | #endif |
| 72 | |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 73 | #if defined (__FreeBSD__) |
Johnny Chen | 7e99647 | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 74 | #include "Plugins/Process/POSIX/ProcessPOSIX.h" |
| 75 | #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 76 | #endif |
| 77 | |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 78 | #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" |
Daniel Malea | a3eb5cd | 2013-01-08 14:55:36 +0000 | [diff] [blame] | 79 | #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" |
Greg Clayton | bd321c5 | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 80 | #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" |
| 81 | |
Greg Clayton | adb909b | 2010-12-16 21:33:41 +0000 | [diff] [blame] | 82 | using namespace lldb; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 83 | using namespace lldb_private; |
| 84 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 85 | void |
| 86 | lldb_private::Initialize () |
| 87 | { |
| 88 | // Make sure we inialize only once |
Caroline Tice | 0aa2e55 | 2011-01-14 00:29:16 +0000 | [diff] [blame] | 89 | static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 90 | static bool g_inited = false; |
| 91 | |
| 92 | Mutex::Locker locker(g_inited_mutex); |
| 93 | if (!g_inited) |
| 94 | { |
| 95 | g_inited = true; |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 96 | Log::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 97 | Timer::Initialize (); |
| 98 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 99 | |
Peter Collingbourne | b7f5945 | 2011-05-19 18:32:34 +0000 | [diff] [blame] | 100 | ABIMacOSX_i386::Initialize(); |
| 101 | ABIMacOSX_arm::Initialize(); |
Peter Collingbourne | aa9719a | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 102 | ABISysV_x86_64::Initialize(); |
Sean Callanan | 32a56ec | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 103 | DisassemblerLLVMC::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | ObjectContainerBSDArchive::Initialize(); |
| 105 | ObjectFileELF::Initialize(); |
Michael Sartain | a807cee | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 106 | SymbolVendorELF::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 107 | SymbolFileDWARF::Initialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | SymbolFileSymtab::Initialize(); |
Greg Clayton | f6e287a | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 109 | UnwindAssemblyInstEmulation::Initialize(); |
Greg Clayton | 888a733 | 2011-04-26 04:39:08 +0000 | [diff] [blame] | 110 | UnwindAssembly_x86::Initialize(); |
Caroline Tice | 080bf61 | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 111 | EmulateInstructionARM::Initialize (); |
Greg Clayton | e9f4982 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 112 | ObjectFilePECOFF::Initialize (); |
Bill Wendling | 0fd911c | 2012-04-05 17:38:07 +0000 | [diff] [blame] | 113 | DynamicLoaderPOSIXDYLD::Initialize (); |
Greg Clayton | a605c64 | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 114 | PlatformFreeBSD::Initialize(); |
| 115 | PlatformLinux::Initialize(); |
Andrew Kaylor | b090668 | 2012-12-14 21:03:37 +0000 | [diff] [blame] | 116 | SymbolFileDWARFDebugMap::Initialize(); |
| 117 | ItaniumABILanguageRuntime::Initialize(); |
Greg Clayton | d815ded | 2012-08-23 21:17:11 +0000 | [diff] [blame] | 118 | #ifndef LLDB_DISABLE_PYTHON |
| 119 | OperatingSystemPython::Initialize(); |
| 120 | #endif |
| 121 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 122 | #if defined (__APPLE__) |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 123 | //---------------------------------------------------------------------- |
| 124 | // Apple/Darwin hosted plugins |
| 125 | //---------------------------------------------------------------------- |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 126 | DynamicLoaderMacOSXDYLD::Initialize(); |
Greg Clayton | 17f3d05 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 127 | DynamicLoaderDarwinKernel::Initialize(); |
Jim Ingham | 642036f | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 128 | AppleObjCRuntimeV2::Initialize(); |
Jim Ingham | 2eac2b9 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 129 | AppleObjCRuntimeV1::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 130 | ObjectContainerUniversalMachO::Initialize(); |
| 131 | ObjectFileMachO::Initialize(); |
Jason Molenda | 5d673ae | 2012-06-01 01:39:46 +0000 | [diff] [blame] | 132 | ProcessKDP::Initialize(); |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 133 | ProcessMachCore::Initialize(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 134 | SymbolVendorMacOSX::Initialize(); |
Jason Molenda | e369aed | 2013-04-05 01:03:25 +0000 | [diff] [blame] | 135 | PlatformDarwinKernel::Initialize(); |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 136 | PlatformRemoteiOS::Initialize(); |
Greg Clayton | b1db658 | 2012-03-20 18:34:04 +0000 | [diff] [blame] | 137 | PlatformMacOSX::Initialize(); |
Greg Clayton | f96c883 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 138 | PlatformiOSSimulator::Initialize(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 139 | #endif |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 140 | #if defined (__linux__) |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 141 | //---------------------------------------------------------------------- |
| 142 | // Linux hosted plugins |
| 143 | //---------------------------------------------------------------------- |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 144 | ProcessLinux::Initialize(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 145 | #endif |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 146 | #if defined (__FreeBSD__) |
Johnny Chen | 7e99647 | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 147 | ProcessFreeBSD::Initialize(); |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 148 | #endif |
Ashok Thirumurthi | f6f5269 | 2013-07-17 16:06:12 +0000 | [diff] [blame] | 149 | |
| 150 | #if defined(__linux__) or defined(__FreeBSD__) |
| 151 | ProcessElfCore::Initialize(); |
| 152 | #endif |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 153 | //---------------------------------------------------------------------- |
| 154 | // Platform agnostic plugins |
| 155 | //---------------------------------------------------------------------- |
| 156 | PlatformRemoteGDBServer::Initialize (); |
Daniel Malea | a3eb5cd | 2013-01-08 14:55:36 +0000 | [diff] [blame] | 157 | ProcessGDBRemote::Initialize(); |
Greg Clayton | bd321c5 | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 158 | DynamicLoaderStatic::Initialize(); |
Greg Clayton | 58e26e0 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 159 | |
Greg Clayton | 52fd984 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 160 | // Scan for any system or user LLDB plug-ins |
| 161 | PluginManager::Initialize(); |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 162 | |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 163 | // The process settings need to know about installed plug-ins, so the Settings must be initialized |
| 164 | // AFTER PluginManager::Initialize is called. |
| 165 | |
| 166 | Debugger::SettingsInitialize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 167 | } |
| 168 | } |
| 169 | |
| 170 | void |
| 171 | lldb_private::WillTerminate() |
| 172 | { |
| 173 | Host::WillTerminate(); |
| 174 | } |
| 175 | |
| 176 | void |
| 177 | lldb_private::Terminate () |
| 178 | { |
| 179 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
Greg Clayton | 52fd984 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 180 | |
| 181 | // Terminate and unload and loaded system or user LLDB plug-ins |
| 182 | PluginManager::Terminate(); |
| 183 | |
Peter Collingbourne | b7f5945 | 2011-05-19 18:32:34 +0000 | [diff] [blame] | 184 | ABIMacOSX_i386::Terminate(); |
| 185 | ABIMacOSX_arm::Terminate(); |
Peter Collingbourne | aa9719a | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 186 | ABISysV_x86_64::Terminate(); |
Sean Callanan | 32a56ec | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 187 | DisassemblerLLVMC::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 188 | ObjectContainerBSDArchive::Terminate(); |
| 189 | ObjectFileELF::Terminate(); |
Michael Sartain | a807cee | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 190 | SymbolVendorELF::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 191 | SymbolFileDWARF::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 192 | SymbolFileSymtab::Terminate(); |
Greg Clayton | f6e287a | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 193 | UnwindAssembly_x86::Terminate(); |
| 194 | UnwindAssemblyInstEmulation::Terminate(); |
Caroline Tice | 080bf61 | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 195 | EmulateInstructionARM::Terminate (); |
Greg Clayton | e9f4982 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 196 | ObjectFilePECOFF::Terminate (); |
Bill Wendling | 0fd911c | 2012-04-05 17:38:07 +0000 | [diff] [blame] | 197 | DynamicLoaderPOSIXDYLD::Terminate (); |
Greg Clayton | a605c64 | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 198 | PlatformFreeBSD::Terminate(); |
| 199 | PlatformLinux::Terminate(); |
Andrew Kaylor | b090668 | 2012-12-14 21:03:37 +0000 | [diff] [blame] | 200 | SymbolFileDWARFDebugMap::Terminate(); |
| 201 | ItaniumABILanguageRuntime::Terminate(); |
Greg Clayton | d815ded | 2012-08-23 21:17:11 +0000 | [diff] [blame] | 202 | #ifndef LLDB_DISABLE_PYTHON |
| 203 | OperatingSystemPython::Terminate(); |
| 204 | #endif |
| 205 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 206 | #if defined (__APPLE__) |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 207 | DynamicLoaderMacOSXDYLD::Terminate(); |
Greg Clayton | 17f3d05 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 208 | DynamicLoaderDarwinKernel::Terminate(); |
Jim Ingham | 2eac2b9 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 209 | AppleObjCRuntimeV2::Terminate(); |
| 210 | AppleObjCRuntimeV1::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 211 | ObjectContainerUniversalMachO::Terminate(); |
| 212 | ObjectFileMachO::Terminate(); |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 213 | ProcessMachCore::Terminate(); |
Jason Molenda | 5d673ae | 2012-06-01 01:39:46 +0000 | [diff] [blame] | 214 | ProcessKDP::Terminate(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 215 | SymbolVendorMacOSX::Terminate(); |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 216 | PlatformMacOSX::Terminate(); |
Jason Molenda | e369aed | 2013-04-05 01:03:25 +0000 | [diff] [blame] | 217 | PlatformDarwinKernel::Terminate(); |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 218 | PlatformRemoteiOS::Terminate(); |
Greg Clayton | f96c883 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 219 | PlatformiOSSimulator::Terminate(); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 220 | #endif |
| 221 | |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 222 | Debugger::SettingsTerminate (); |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 223 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 224 | #if defined (__linux__) |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 225 | ProcessLinux::Terminate(); |
Eli Friedman | e5cadba | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 226 | #endif |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 227 | |
| 228 | #if defined (__FreeBSD__) |
Johnny Chen | 7e99647 | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 229 | ProcessFreeBSD::Terminate(); |
Johnny Chen | 4b66329 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 230 | #endif |
Ashok Thirumurthi | f6f5269 | 2013-07-17 16:06:12 +0000 | [diff] [blame] | 231 | |
| 232 | #if defined(__linux__) or defined(__FreeBSD__) |
| 233 | ProcessElfCore::Terminate(); |
| 234 | #endif |
Daniel Malea | a3eb5cd | 2013-01-08 14:55:36 +0000 | [diff] [blame] | 235 | ProcessGDBRemote::Terminate(); |
Greg Clayton | bd321c5 | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 236 | DynamicLoaderStatic::Terminate(); |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 237 | |
| 238 | Log::Terminate(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Daniel Malea | 3dd21ab | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 241 | #if defined (__APPLE__) |
Sean Callanan | 6778c99 | 2013-03-07 22:29:06 +0000 | [diff] [blame] | 242 | extern "C" const unsigned char liblldb_coreVersionString[]; |
Greg Clayton | 54ad8cf | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 243 | #else |
| 244 | |
| 245 | #include "clang/Basic/Version.h" |
| 246 | |
| 247 | static const char * |
| 248 | GetLLDBRevision() |
| 249 | { |
| 250 | #ifdef LLDB_REVISION |
| 251 | return LLDB_REVISION; |
| 252 | #else |
| 253 | return NULL; |
| 254 | #endif |
| 255 | } |
| 256 | |
| 257 | static const char * |
| 258 | GetLLDBRepository() |
| 259 | { |
| 260 | #ifdef LLDB_REPOSITORY |
| 261 | return LLDB_REPOSITORY; |
| 262 | #else |
| 263 | return NULL; |
| 264 | #endif |
| 265 | } |
| 266 | |
Daniel Malea | 3dd21ab | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 267 | #endif |
| 268 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 269 | const char * |
| 270 | lldb_private::GetVersion () |
| 271 | { |
Daniel Malea | 3dd21ab | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 272 | #if defined (__APPLE__) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 273 | static char g_version_string[32]; |
| 274 | if (g_version_string[0] == '\0') |
Sean Callanan | 6778c99 | 2013-03-07 22:29:06 +0000 | [diff] [blame] | 275 | { |
| 276 | const char *version_string = ::strstr ((const char *)liblldb_coreVersionString, "PROJECT:"); |
| 277 | |
| 278 | if (version_string) |
| 279 | version_string += sizeof("PROJECT:") - 1; |
| 280 | else |
| 281 | version_string = "unknown"; |
| 282 | |
| 283 | const char *newline_loc = strchr(version_string, '\n'); |
| 284 | |
| 285 | size_t version_len = sizeof(g_version_string); |
| 286 | |
| 287 | if (newline_loc && (newline_loc - version_string < version_len)) |
| 288 | version_len = newline_loc - version_string; |
| 289 | |
| 290 | ::strncpy(g_version_string, version_string, version_len); |
| 291 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 292 | |
| 293 | return g_version_string; |
Daniel Malea | 3dd21ab | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 294 | #else |
| 295 | // On Linux/FreeBSD/Windows, report a version number in the same style as the clang tool. |
Greg Clayton | 54ad8cf | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 296 | static std::string g_version_str; |
| 297 | if (g_version_str.empty()) |
| 298 | { |
| 299 | g_version_str += "lldb version "; |
| 300 | g_version_str += CLANG_VERSION_STRING; |
| 301 | const char * lldb_repo = GetLLDBRepository(); |
| 302 | if (lldb_repo) |
| 303 | { |
| 304 | g_version_str += " ("; |
| 305 | g_version_str += lldb_repo; |
| 306 | } |
Daniel Malea | 3dd21ab | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 307 | |
Greg Clayton | 54ad8cf | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 308 | const char *lldb_rev = GetLLDBRevision(); |
| 309 | if (lldb_rev) |
| 310 | { |
| 311 | g_version_str += " revision "; |
| 312 | g_version_str += lldb_rev; |
| 313 | } |
| 314 | std::string clang_rev (clang::getClangRevision()); |
| 315 | if (clang_rev.length() > 0) |
| 316 | { |
| 317 | g_version_str += " clang revision "; |
| 318 | g_version_str += clang_rev; |
| 319 | } |
| 320 | std::string llvm_rev (clang::getLLVMRevision()); |
| 321 | if (llvm_rev.length() > 0) |
| 322 | { |
| 323 | g_version_str += " llvm revision "; |
| 324 | g_version_str += llvm_rev; |
| 325 | } |
Daniel Malea | 3dd21ab | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 326 | |
Greg Clayton | 54ad8cf | 2013-02-28 18:09:18 +0000 | [diff] [blame] | 327 | if (lldb_repo) |
| 328 | g_version_str += ")"; |
| 329 | } |
| 330 | return g_version_str.c_str(); |
Daniel Malea | 3dd21ab | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 331 | #endif |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 334 | const char * |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 335 | lldb_private::GetVoteAsCString (Vote vote) |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 336 | { |
Greg Clayton | f04d661 | 2010-09-03 22:45:01 +0000 | [diff] [blame] | 337 | switch (vote) |
| 338 | { |
| 339 | case eVoteNo: return "no"; |
| 340 | case eVoteNoOpinion: return "no opinion"; |
| 341 | case eVoteYes: return "yes"; |
Greg Clayton | f04d661 | 2010-09-03 22:45:01 +0000 | [diff] [blame] | 342 | } |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 343 | return "invalid"; |
| 344 | } |
| 345 | |
Greg Clayton | 3fed8b9 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 346 | |
| 347 | const char * |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 348 | lldb_private::GetSectionTypeAsCString (SectionType sect_type) |
Greg Clayton | 3fed8b9 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 349 | { |
| 350 | switch (sect_type) |
| 351 | { |
| 352 | case eSectionTypeInvalid: return "invalid"; |
| 353 | case eSectionTypeCode: return "code"; |
| 354 | case eSectionTypeContainer: return "container"; |
| 355 | case eSectionTypeData: return "data"; |
| 356 | case eSectionTypeDataCString: return "data-cstr"; |
| 357 | case eSectionTypeDataCStringPointers: return "data-cstr-ptr"; |
| 358 | case eSectionTypeDataSymbolAddress: return "data-symbol-addr"; |
| 359 | case eSectionTypeData4: return "data-4-byte"; |
| 360 | case eSectionTypeData8: return "data-8-byte"; |
| 361 | case eSectionTypeData16: return "data-16-byte"; |
| 362 | case eSectionTypeDataPointers: return "data-ptrs"; |
| 363 | case eSectionTypeDebug: return "debug"; |
| 364 | case eSectionTypeZeroFill: return "zero-fill"; |
| 365 | case eSectionTypeDataObjCMessageRefs: return "objc-message-refs"; |
| 366 | case eSectionTypeDataObjCCFStrings: return "objc-cfstrings"; |
| 367 | case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev"; |
| 368 | case eSectionTypeDWARFDebugAranges: return "dwarf-aranges"; |
| 369 | case eSectionTypeDWARFDebugFrame: return "dwarf-frame"; |
| 370 | case eSectionTypeDWARFDebugInfo: return "dwarf-info"; |
| 371 | case eSectionTypeDWARFDebugLine: return "dwarf-line"; |
| 372 | case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; |
| 373 | case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; |
| 374 | case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames"; |
| 375 | case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes"; |
| 376 | case eSectionTypeDWARFDebugRanges: return "dwarf-ranges"; |
| 377 | case eSectionTypeDWARFDebugStr: return "dwarf-str"; |
Michael Sartain | a807cee | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 378 | case eSectionTypeELFSymbolTable: return "elf-symbol-table"; |
| 379 | case eSectionTypeELFDynamicSymbols: return "elf-dynamic-symbols"; |
| 380 | case eSectionTypeELFRelocationEntries: return "elf-relocation-entries"; |
| 381 | case eSectionTypeELFDynamicLinkInfo: return "elf-dynamic-link-info"; |
Greg Clayton | f6e3de2 | 2011-09-28 17:06:40 +0000 | [diff] [blame] | 382 | case eSectionTypeDWARFAppleNames: return "apple-names"; |
| 383 | case eSectionTypeDWARFAppleTypes: return "apple-types"; |
Greg Clayton | 00db215 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 384 | case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces"; |
Greg Clayton | 24a6bd9 | 2011-10-27 17:55:14 +0000 | [diff] [blame] | 385 | case eSectionTypeDWARFAppleObjC: return "apple-objc"; |
Greg Clayton | 3fed8b9 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 386 | case eSectionTypeEHFrame: return "eh-frame"; |
| 387 | case eSectionTypeOther: return "regular"; |
| 388 | } |
| 389 | return "unknown"; |
| 390 | |
| 391 | } |
| 392 | |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 393 | bool |
| 394 | lldb_private::NameMatches (const char *name, |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 395 | NameMatchType match_type, |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 396 | const char *match) |
| 397 | { |
| 398 | if (match_type == eNameMatchIgnore) |
| 399 | return true; |
| 400 | |
| 401 | if (name == match) |
| 402 | return true; |
| 403 | |
| 404 | if (name && match) |
| 405 | { |
| 406 | llvm::StringRef name_sref(name); |
| 407 | llvm::StringRef match_sref(match); |
| 408 | switch (match_type) |
| 409 | { |
| 410 | case eNameMatchIgnore: |
| 411 | return true; |
| 412 | case eNameMatchEquals: return name_sref == match_sref; |
| 413 | case eNameMatchContains: return name_sref.find (match_sref) != llvm::StringRef::npos; |
| 414 | case eNameMatchStartsWith: return name_sref.startswith (match_sref); |
| 415 | case eNameMatchEndsWith: return name_sref.endswith (match_sref); |
| 416 | case eNameMatchRegularExpression: |
| 417 | { |
| 418 | RegularExpression regex (match); |
| 419 | return regex.Execute (name); |
| 420 | } |
| 421 | break; |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | return false; |
| 425 | } |