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