Chris Lattner | 30fdc8d | 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 | 93a6430 | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "lldb/lldb-private.h" |
| 13 | #include "lldb/lldb-private-log.h" |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 14 | #include "lldb/Core/ArchSpec.h" |
Stephen Wilson | 28c16d9 | 2011-03-13 00:00:32 +0000 | [diff] [blame] | 15 | #include "lldb/Core/Debugger.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 16 | #include "lldb/Core/Log.h" |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 17 | #include "lldb/Core/PluginManager.h" |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 18 | #include "lldb/Core/RegularExpression.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Timer.h" |
| 20 | #include "lldb/Host/Host.h" |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 21 | #include "lldb/Host/Mutex.h" |
Greg Clayton | 3c310a1 | 2010-12-16 21:36:30 +0000 | [diff] [blame] | 22 | #include "lldb/Target/Target.h" |
| 23 | #include "lldb/Target/Thread.h" |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 24 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/StringRef.h" |
| 26 | |
Peter Collingbourne | 1b27dac | 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 | a09bfca | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 29 | #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" |
Sean Callanan | 95e5c63 | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 30 | #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" |
Caroline Tice | ad379efc | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 31 | #include "Plugins/Instruction/ARM/EmulateInstructionARM.h" |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 32 | #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" |
| 33 | #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h" |
| 34 | #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" |
| 35 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" |
| 36 | #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" |
| 37 | #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" |
Greg Clayton | 078daac | 2011-04-25 21:07:40 +0000 | [diff] [blame] | 38 | #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" |
Greg Clayton | ffc922e3 | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 39 | #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" |
Greg Clayton | f754f88 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 40 | #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" |
Greg Clayton | d10a038 | 2012-02-27 19:00:34 +0000 | [diff] [blame] | 41 | #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h" |
Greg Clayton | ea5e0cc | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 42 | #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" |
| 43 | #include "Plugins/Platform/Linux/PlatformLinux.h" |
Andrew Kaylor | 7b6376b | 2012-12-14 21:03:37 +0000 | [diff] [blame] | 44 | #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" |
Greg Clayton | b3e7760 | 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 | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 48 | #if defined (__APPLE__) |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 49 | #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" |
Greg Clayton | 944b828 | 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 | 2a5e0f0 | 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 | e13a8db | 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 | 3a29bdb | 2011-07-17 20:36:25 +0000 | [diff] [blame] | 56 | #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 57 | #include "Plugins/Platform/MacOSX/PlatformMacOSX.h" |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 58 | #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" |
Greg Clayton | 722cec2 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 59 | #include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 60 | #endif |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 61 | |
Greg Clayton | c3776bf | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 62 | #include "Plugins/Process/mach-core/ProcessMachCore.h" |
| 63 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 64 | #if defined (__linux__) |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 65 | #include "Plugins/Process/Linux/ProcessLinux.h" |
Stephen Wilson | e6f9f66 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
Johnny Chen | 8f3d838 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 68 | #if defined (__FreeBSD__) |
Johnny Chen | 30213ff | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 69 | #include "Plugins/Process/POSIX/ProcessPOSIX.h" |
| 70 | #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" |
Johnny Chen | 8f3d838 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 71 | #endif |
| 72 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 73 | #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" |
Daniel Malea | 97059d4 | 2013-01-08 14:55:36 +0000 | [diff] [blame] | 74 | #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" |
Greg Clayton | fc7117a | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 75 | #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" |
| 76 | |
Greg Clayton | ce6d19a | 2010-12-16 21:33:41 +0000 | [diff] [blame] | 77 | using namespace lldb; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 78 | using namespace lldb_private; |
| 79 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | void |
| 81 | lldb_private::Initialize () |
| 82 | { |
| 83 | // Make sure we inialize only once |
Caroline Tice | 2f88aad | 2011-01-14 00:29:16 +0000 | [diff] [blame] | 84 | static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 85 | static bool g_inited = false; |
| 86 | |
| 87 | Mutex::Locker locker(g_inited_mutex); |
| 88 | if (!g_inited) |
| 89 | { |
| 90 | g_inited = true; |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 91 | Log::Initialize(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 92 | Timer::Initialize (); |
| 93 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 94 | |
Peter Collingbourne | 1b27dac | 2011-05-19 18:32:34 +0000 | [diff] [blame] | 95 | ABIMacOSX_i386::Initialize(); |
| 96 | ABIMacOSX_arm::Initialize(); |
Peter Collingbourne | a09bfca | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 97 | ABISysV_x86_64::Initialize(); |
Sean Callanan | 95e5c63 | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 98 | DisassemblerLLVMC::Initialize(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 99 | ObjectContainerBSDArchive::Initialize(); |
| 100 | ObjectFileELF::Initialize(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 101 | SymbolFileDWARF::Initialize(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 102 | SymbolFileSymtab::Initialize(); |
Greg Clayton | ffc922e3 | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 103 | UnwindAssemblyInstEmulation::Initialize(); |
Greg Clayton | 2ed751b | 2011-04-26 04:39:08 +0000 | [diff] [blame] | 104 | UnwindAssembly_x86::Initialize(); |
Caroline Tice | ad379efc | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 105 | EmulateInstructionARM::Initialize (); |
Greg Clayton | f754f88 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 106 | ObjectFilePECOFF::Initialize (); |
Bill Wendling | e50ab40 | 2012-04-05 17:38:07 +0000 | [diff] [blame] | 107 | DynamicLoaderPOSIXDYLD::Initialize (); |
Greg Clayton | ea5e0cc | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 108 | PlatformFreeBSD::Initialize(); |
| 109 | PlatformLinux::Initialize(); |
Andrew Kaylor | 7b6376b | 2012-12-14 21:03:37 +0000 | [diff] [blame] | 110 | SymbolFileDWARFDebugMap::Initialize(); |
| 111 | ItaniumABILanguageRuntime::Initialize(); |
Greg Clayton | b3e7760 | 2012-08-23 21:17:11 +0000 | [diff] [blame] | 112 | #ifndef LLDB_DISABLE_PYTHON |
| 113 | OperatingSystemPython::Initialize(); |
| 114 | #endif |
| 115 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 116 | #if defined (__APPLE__) |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 117 | //---------------------------------------------------------------------- |
| 118 | // Apple/Darwin hosted plugins |
| 119 | //---------------------------------------------------------------------- |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 120 | DynamicLoaderMacOSXDYLD::Initialize(); |
Greg Clayton | 944b828 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 121 | DynamicLoaderDarwinKernel::Initialize(); |
| 122 | OperatingSystemDarwinKernel::Initialize(); |
Jim Ingham | 2277701 | 2010-09-23 02:01:19 +0000 | [diff] [blame] | 123 | AppleObjCRuntimeV2::Initialize(); |
Jim Ingham | 2a5e0f0 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 124 | AppleObjCRuntimeV1::Initialize(); |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 125 | ObjectContainerUniversalMachO::Initialize(); |
| 126 | ObjectFileMachO::Initialize(); |
Jason Molenda | 382dcfd | 2012-06-01 01:39:46 +0000 | [diff] [blame] | 127 | ProcessKDP::Initialize(); |
Greg Clayton | c3776bf | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 128 | ProcessMachCore::Initialize(); |
Stephen Wilson | e6f9f66 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 129 | SymbolVendorMacOSX::Initialize(); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 130 | PlatformRemoteiOS::Initialize(); |
Greg Clayton | b3a40ba | 2012-03-20 18:34:04 +0000 | [diff] [blame] | 131 | PlatformMacOSX::Initialize(); |
Greg Clayton | 722cec2 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 132 | PlatformiOSSimulator::Initialize(); |
Stephen Wilson | e6f9f66 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 133 | #endif |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 134 | #if defined (__linux__) |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 135 | //---------------------------------------------------------------------- |
| 136 | // Linux hosted plugins |
| 137 | //---------------------------------------------------------------------- |
Stephen Wilson | e6f9f66 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 138 | ProcessLinux::Initialize(); |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 139 | #endif |
Johnny Chen | 8f3d838 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 140 | #if defined (__FreeBSD__) |
Johnny Chen | 30213ff | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 141 | ProcessFreeBSD::Initialize(); |
Johnny Chen | 8f3d838 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 142 | #endif |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 143 | //---------------------------------------------------------------------- |
| 144 | // Platform agnostic plugins |
| 145 | //---------------------------------------------------------------------- |
| 146 | PlatformRemoteGDBServer::Initialize (); |
Daniel Malea | 97059d4 | 2013-01-08 14:55:36 +0000 | [diff] [blame] | 147 | ProcessGDBRemote::Initialize(); |
Greg Clayton | fc7117a | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 148 | DynamicLoaderStatic::Initialize(); |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 149 | |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 150 | // Scan for any system or user LLDB plug-ins |
| 151 | PluginManager::Initialize(); |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 152 | |
Caroline Tice | 20bd37f | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 153 | // The process settings need to know about installed plug-ins, so the Settings must be initialized |
| 154 | // AFTER PluginManager::Initialize is called. |
| 155 | |
| 156 | Debugger::SettingsInitialize(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
| 160 | void |
| 161 | lldb_private::WillTerminate() |
| 162 | { |
| 163 | Host::WillTerminate(); |
| 164 | } |
| 165 | |
| 166 | void |
| 167 | lldb_private::Terminate () |
| 168 | { |
| 169 | Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); |
Greg Clayton | 4272cc7 | 2011-02-02 02:24:04 +0000 | [diff] [blame] | 170 | |
| 171 | // Terminate and unload and loaded system or user LLDB plug-ins |
| 172 | PluginManager::Terminate(); |
| 173 | |
Peter Collingbourne | 1b27dac | 2011-05-19 18:32:34 +0000 | [diff] [blame] | 174 | ABIMacOSX_i386::Terminate(); |
| 175 | ABIMacOSX_arm::Terminate(); |
Peter Collingbourne | a09bfca | 2011-05-19 17:34:40 +0000 | [diff] [blame] | 176 | ABISysV_x86_64::Terminate(); |
Sean Callanan | 95e5c63 | 2012-02-17 00:53:45 +0000 | [diff] [blame] | 177 | DisassemblerLLVMC::Terminate(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 178 | ObjectContainerBSDArchive::Terminate(); |
| 179 | ObjectFileELF::Terminate(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 180 | SymbolFileDWARF::Terminate(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 181 | SymbolFileSymtab::Terminate(); |
Greg Clayton | ffc922e3 | 2011-04-25 21:05:07 +0000 | [diff] [blame] | 182 | UnwindAssembly_x86::Terminate(); |
| 183 | UnwindAssemblyInstEmulation::Terminate(); |
Caroline Tice | ad379efc | 2011-04-05 18:46:00 +0000 | [diff] [blame] | 184 | EmulateInstructionARM::Terminate (); |
Greg Clayton | f754f88 | 2011-09-09 20:33:05 +0000 | [diff] [blame] | 185 | ObjectFilePECOFF::Terminate (); |
Bill Wendling | e50ab40 | 2012-04-05 17:38:07 +0000 | [diff] [blame] | 186 | DynamicLoaderPOSIXDYLD::Terminate (); |
Greg Clayton | ea5e0cc | 2012-02-27 19:12:12 +0000 | [diff] [blame] | 187 | PlatformFreeBSD::Terminate(); |
| 188 | PlatformLinux::Terminate(); |
Andrew Kaylor | 7b6376b | 2012-12-14 21:03:37 +0000 | [diff] [blame] | 189 | SymbolFileDWARFDebugMap::Terminate(); |
| 190 | ItaniumABILanguageRuntime::Terminate(); |
Greg Clayton | b3e7760 | 2012-08-23 21:17:11 +0000 | [diff] [blame] | 191 | #ifndef LLDB_DISABLE_PYTHON |
| 192 | OperatingSystemPython::Terminate(); |
| 193 | #endif |
| 194 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 195 | #if defined (__APPLE__) |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 196 | DynamicLoaderMacOSXDYLD::Terminate(); |
Greg Clayton | 944b828 | 2011-08-22 22:30:57 +0000 | [diff] [blame] | 197 | DynamicLoaderDarwinKernel::Terminate(); |
| 198 | OperatingSystemDarwinKernel::Terminate(); |
Jim Ingham | 2a5e0f0 | 2010-11-04 18:30:59 +0000 | [diff] [blame] | 199 | AppleObjCRuntimeV2::Terminate(); |
| 200 | AppleObjCRuntimeV1::Terminate(); |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 201 | ObjectContainerUniversalMachO::Terminate(); |
| 202 | ObjectFileMachO::Terminate(); |
Greg Clayton | c3776bf | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 203 | ProcessMachCore::Terminate(); |
Jason Molenda | 382dcfd | 2012-06-01 01:39:46 +0000 | [diff] [blame] | 204 | ProcessKDP::Terminate(); |
Stephen Wilson | e6f9f66 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 205 | SymbolVendorMacOSX::Terminate(); |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 206 | PlatformMacOSX::Terminate(); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 207 | PlatformRemoteiOS::Terminate(); |
Greg Clayton | 722cec2 | 2012-02-25 06:56:35 +0000 | [diff] [blame] | 208 | PlatformiOSSimulator::Terminate(); |
Stephen Wilson | e6f9f66 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 209 | #endif |
| 210 | |
Caroline Tice | 20bd37f | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 211 | Debugger::SettingsTerminate (); |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 212 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 213 | #if defined (__linux__) |
Stephen Wilson | e6f9f66 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 214 | ProcessLinux::Terminate(); |
Eli Friedman | e13a8db | 2010-06-13 19:36:42 +0000 | [diff] [blame] | 215 | #endif |
Johnny Chen | 8f3d838 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 216 | |
| 217 | #if defined (__FreeBSD__) |
Johnny Chen | 30213ff | 2012-01-05 19:17:38 +0000 | [diff] [blame] | 218 | ProcessFreeBSD::Terminate(); |
Johnny Chen | 8f3d838 | 2011-08-02 20:52:42 +0000 | [diff] [blame] | 219 | #endif |
Greg Clayton | fc7117a | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 220 | |
Daniel Malea | 97059d4 | 2013-01-08 14:55:36 +0000 | [diff] [blame] | 221 | ProcessGDBRemote::Terminate(); |
Greg Clayton | fc7117a | 2011-03-05 01:04:56 +0000 | [diff] [blame] | 222 | DynamicLoaderStatic::Terminate(); |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 223 | |
| 224 | Log::Terminate(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 227 | |
| 228 | #if defined (__APPLE__) |
Greg Clayton | fc36f791 | 2011-03-22 01:14:58 +0000 | [diff] [blame] | 229 | extern "C" const double liblldb_coreVersionNumber; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame^] | 230 | #else |
| 231 | |
| 232 | #include "clang/Basic/Version.h" |
| 233 | |
| 234 | static const char * |
| 235 | GetLLDBRevision() |
| 236 | { |
| 237 | #ifdef LLDB_REVISION |
| 238 | return LLDB_REVISION; |
| 239 | #else |
| 240 | return NULL; |
| 241 | #endif |
| 242 | } |
| 243 | |
| 244 | static const char * |
| 245 | GetLLDBRepository() |
| 246 | { |
| 247 | #ifdef LLDB_REPOSITORY |
| 248 | return LLDB_REPOSITORY; |
| 249 | #else |
| 250 | return NULL; |
| 251 | #endif |
| 252 | } |
| 253 | |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 254 | #endif |
| 255 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 256 | const char * |
| 257 | lldb_private::GetVersion () |
| 258 | { |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 259 | #if defined (__APPLE__) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 260 | static char g_version_string[32]; |
| 261 | if (g_version_string[0] == '\0') |
Greg Clayton | fc36f791 | 2011-03-22 01:14:58 +0000 | [diff] [blame] | 262 | ::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", liblldb_coreVersionNumber); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 263 | |
| 264 | return g_version_string; |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 265 | #else |
| 266 | // On Linux/FreeBSD/Windows, report a version number in the same style as the clang tool. |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame^] | 267 | static std::string g_version_str; |
| 268 | if (g_version_str.empty()) |
| 269 | { |
| 270 | g_version_str += "lldb version "; |
| 271 | g_version_str += CLANG_VERSION_STRING; |
| 272 | const char * lldb_repo = GetLLDBRepository(); |
| 273 | if (lldb_repo) |
| 274 | { |
| 275 | g_version_str += " ("; |
| 276 | g_version_str += lldb_repo; |
| 277 | } |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 278 | |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame^] | 279 | const char *lldb_rev = GetLLDBRevision(); |
| 280 | if (lldb_rev) |
| 281 | { |
| 282 | g_version_str += " revision "; |
| 283 | g_version_str += lldb_rev; |
| 284 | } |
| 285 | std::string clang_rev (clang::getClangRevision()); |
| 286 | if (clang_rev.length() > 0) |
| 287 | { |
| 288 | g_version_str += " clang revision "; |
| 289 | g_version_str += clang_rev; |
| 290 | } |
| 291 | std::string llvm_rev (clang::getLLVMRevision()); |
| 292 | if (llvm_rev.length() > 0) |
| 293 | { |
| 294 | g_version_str += " llvm revision "; |
| 295 | g_version_str += llvm_rev; |
| 296 | } |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 297 | |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 +0000 | [diff] [blame^] | 298 | if (lldb_repo) |
| 299 | g_version_str += ")"; |
| 300 | } |
| 301 | return g_version_str.c_str(); |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 302 | #endif |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 303 | } |
| 304 | |
Greg Clayton | 2cad65a | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 305 | const char * |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 306 | lldb_private::GetVoteAsCString (Vote vote) |
Greg Clayton | 2cad65a | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 307 | { |
Greg Clayton | 1346f7e | 2010-09-03 22:45:01 +0000 | [diff] [blame] | 308 | switch (vote) |
| 309 | { |
| 310 | case eVoteNo: return "no"; |
| 311 | case eVoteNoOpinion: return "no opinion"; |
| 312 | case eVoteYes: return "yes"; |
Greg Clayton | 1346f7e | 2010-09-03 22:45:01 +0000 | [diff] [blame] | 313 | } |
Greg Clayton | 2cad65a | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 314 | return "invalid"; |
| 315 | } |
| 316 | |
Greg Clayton | 8941142 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 317 | |
| 318 | const char * |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 319 | lldb_private::GetSectionTypeAsCString (SectionType sect_type) |
Greg Clayton | 8941142 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 320 | { |
| 321 | switch (sect_type) |
| 322 | { |
| 323 | case eSectionTypeInvalid: return "invalid"; |
| 324 | case eSectionTypeCode: return "code"; |
| 325 | case eSectionTypeContainer: return "container"; |
| 326 | case eSectionTypeData: return "data"; |
| 327 | case eSectionTypeDataCString: return "data-cstr"; |
| 328 | case eSectionTypeDataCStringPointers: return "data-cstr-ptr"; |
| 329 | case eSectionTypeDataSymbolAddress: return "data-symbol-addr"; |
| 330 | case eSectionTypeData4: return "data-4-byte"; |
| 331 | case eSectionTypeData8: return "data-8-byte"; |
| 332 | case eSectionTypeData16: return "data-16-byte"; |
| 333 | case eSectionTypeDataPointers: return "data-ptrs"; |
| 334 | case eSectionTypeDebug: return "debug"; |
| 335 | case eSectionTypeZeroFill: return "zero-fill"; |
| 336 | case eSectionTypeDataObjCMessageRefs: return "objc-message-refs"; |
| 337 | case eSectionTypeDataObjCCFStrings: return "objc-cfstrings"; |
| 338 | case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev"; |
| 339 | case eSectionTypeDWARFDebugAranges: return "dwarf-aranges"; |
| 340 | case eSectionTypeDWARFDebugFrame: return "dwarf-frame"; |
| 341 | case eSectionTypeDWARFDebugInfo: return "dwarf-info"; |
| 342 | case eSectionTypeDWARFDebugLine: return "dwarf-line"; |
| 343 | case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; |
| 344 | case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; |
| 345 | case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames"; |
| 346 | case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes"; |
| 347 | case eSectionTypeDWARFDebugRanges: return "dwarf-ranges"; |
| 348 | case eSectionTypeDWARFDebugStr: return "dwarf-str"; |
Greg Clayton | 1767440 | 2011-09-28 17:06:40 +0000 | [diff] [blame] | 349 | case eSectionTypeDWARFAppleNames: return "apple-names"; |
| 350 | case eSectionTypeDWARFAppleTypes: return "apple-types"; |
Greg Clayton | 7f99513 | 2011-10-04 22:41:51 +0000 | [diff] [blame] | 351 | case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces"; |
Greg Clayton | 5009f9d | 2011-10-27 17:55:14 +0000 | [diff] [blame] | 352 | case eSectionTypeDWARFAppleObjC: return "apple-objc"; |
Greg Clayton | 8941142 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 353 | case eSectionTypeEHFrame: return "eh-frame"; |
| 354 | case eSectionTypeOther: return "regular"; |
| 355 | } |
| 356 | return "unknown"; |
| 357 | |
| 358 | } |
| 359 | |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 360 | bool |
| 361 | lldb_private::NameMatches (const char *name, |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 362 | NameMatchType match_type, |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 363 | const char *match) |
| 364 | { |
| 365 | if (match_type == eNameMatchIgnore) |
| 366 | return true; |
| 367 | |
| 368 | if (name == match) |
| 369 | return true; |
| 370 | |
| 371 | if (name && match) |
| 372 | { |
| 373 | llvm::StringRef name_sref(name); |
| 374 | llvm::StringRef match_sref(match); |
| 375 | switch (match_type) |
| 376 | { |
| 377 | case eNameMatchIgnore: |
| 378 | return true; |
| 379 | case eNameMatchEquals: return name_sref == match_sref; |
| 380 | case eNameMatchContains: return name_sref.find (match_sref) != llvm::StringRef::npos; |
| 381 | case eNameMatchStartsWith: return name_sref.startswith (match_sref); |
| 382 | case eNameMatchEndsWith: return name_sref.endswith (match_sref); |
| 383 | case eNameMatchRegularExpression: |
| 384 | { |
| 385 | RegularExpression regex (match); |
| 386 | return regex.Execute (name); |
| 387 | } |
| 388 | break; |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | return false; |
| 392 | } |