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