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