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