blob: 4cb0aaed2d85b7ca12aa6c9c2c6b56f428e4ef7f [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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 Malea93a64302012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Chris Lattner30fdc8d2010-06-08 16:52:24 +000012#include "lldb/lldb-private.h"
13#include "lldb/lldb-private-log.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000014#include "lldb/Core/ArchSpec.h"
Stephen Wilson28c16d92011-03-13 00:00:32 +000015#include "lldb/Core/Debugger.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000016#include "lldb/Core/Log.h"
Greg Clayton4272cc72011-02-02 02:24:04 +000017#include "lldb/Core/PluginManager.h"
Greg Claytone996fd32011-03-08 22:40:15 +000018#include "lldb/Core/RegularExpression.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000019#include "lldb/Core/Timer.h"
20#include "lldb/Host/Host.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000021#include "lldb/Host/Mutex.h"
Greg Clayton3c310a12010-12-16 21:36:30 +000022#include "lldb/Target/Target.h"
23#include "lldb/Target/Thread.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000024
Greg Claytone996fd32011-03-08 22:40:15 +000025#include "llvm/ADT/StringRef.h"
26
Peter Collingbourne1b27dac2011-05-19 18:32:34 +000027#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
28#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
Peter Collingbournea09bfca2011-05-19 17:34:40 +000029#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
Sean Callanan95e5c632012-02-17 00:53:45 +000030#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
Caroline Ticead379efc2011-04-05 18:46:00 +000031#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000032#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
33#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
34#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
35#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
36#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
37#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
Greg Clayton078daac2011-04-25 21:07:40 +000038#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
Greg Claytonffc922e32011-04-25 21:05:07 +000039#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
Greg Claytonf754f882011-09-09 20:33:05 +000040#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
Greg Claytond10a0382012-02-27 19:00:34 +000041#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
Greg Claytonea5e0cc2012-02-27 19:12:12 +000042#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
43#include "Plugins/Platform/Linux/PlatformLinux.h"
Andrew Kaylor7b6376b2012-12-14 21:03:37 +000044#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
Greg Claytonb3e77602012-08-23 21:17:11 +000045#ifndef LLDB_DISABLE_PYTHON
46#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
47#endif
Greg Claytone996fd32011-03-08 22:40:15 +000048#if defined (__APPLE__)
Eli Friedmane13a8db2010-06-13 19:36:42 +000049#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
Greg Clayton944b8282011-08-22 22:30:57 +000050#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
51#include "Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h"
Jim Ingham2a5e0f02010-11-04 18:30:59 +000052#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
53#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000054#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
55#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
Greg Clayton3a29bdb2011-07-17 20:36:25 +000056#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
Greg Claytone996fd32011-03-08 22:40:15 +000057#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
Greg Claytonded470d2011-03-19 01:12:21 +000058#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
Greg Clayton722cec22012-02-25 06:56:35 +000059#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000060#endif
Chris Lattner30fdc8d2010-06-08 16:52:24 +000061
Greg Claytonc3776bf2012-02-09 06:16:32 +000062#include "Plugins/Process/mach-core/ProcessMachCore.h"
63
Greg Claytone996fd32011-03-08 22:40:15 +000064#if defined (__linux__)
Greg Claytone996fd32011-03-08 22:40:15 +000065#include "Plugins/Process/Linux/ProcessLinux.h"
Stephen Wilsone6f9f662010-07-24 02:19:04 +000066#endif
67
Johnny Chen8f3d8382011-08-02 20:52:42 +000068#if defined (__FreeBSD__)
Johnny Chen30213ff2012-01-05 19:17:38 +000069#include "Plugins/Process/POSIX/ProcessPOSIX.h"
70#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
Johnny Chen8f3d8382011-08-02 20:52:42 +000071#endif
72
Greg Clayton1cb64962011-03-24 04:28:38 +000073#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
Daniel Malea97059d42013-01-08 14:55:36 +000074#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
Greg Claytonfc7117a2011-03-05 01:04:56 +000075#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
76
Greg Claytonce6d19a2010-12-16 21:33:41 +000077using namespace lldb;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000078using namespace lldb_private;
79
Chris Lattner30fdc8d2010-06-08 16:52:24 +000080void
81lldb_private::Initialize ()
82{
83 // Make sure we inialize only once
Caroline Tice2f88aad2011-01-14 00:29:16 +000084 static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000085 static bool g_inited = false;
86
87 Mutex::Locker locker(g_inited_mutex);
88 if (!g_inited)
89 {
90 g_inited = true;
Greg Clayton99d0faf2010-11-18 23:32:35 +000091 Log::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000092 Timer::Initialize ();
93 Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
Greg Clayton99d0faf2010-11-18 23:32:35 +000094
Peter Collingbourne1b27dac2011-05-19 18:32:34 +000095 ABIMacOSX_i386::Initialize();
96 ABIMacOSX_arm::Initialize();
Peter Collingbournea09bfca2011-05-19 17:34:40 +000097 ABISysV_x86_64::Initialize();
Sean Callanan95e5c632012-02-17 00:53:45 +000098 DisassemblerLLVMC::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000099 ObjectContainerBSDArchive::Initialize();
100 ObjectFileELF::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000101 SymbolFileDWARF::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000102 SymbolFileSymtab::Initialize();
Greg Claytonffc922e32011-04-25 21:05:07 +0000103 UnwindAssemblyInstEmulation::Initialize();
Greg Clayton2ed751b2011-04-26 04:39:08 +0000104 UnwindAssembly_x86::Initialize();
Caroline Ticead379efc2011-04-05 18:46:00 +0000105 EmulateInstructionARM::Initialize ();
Greg Claytonf754f882011-09-09 20:33:05 +0000106 ObjectFilePECOFF::Initialize ();
Bill Wendlinge50ab402012-04-05 17:38:07 +0000107 DynamicLoaderPOSIXDYLD::Initialize ();
Greg Claytonea5e0cc2012-02-27 19:12:12 +0000108 PlatformFreeBSD::Initialize();
109 PlatformLinux::Initialize();
Andrew Kaylor7b6376b2012-12-14 21:03:37 +0000110 SymbolFileDWARFDebugMap::Initialize();
111 ItaniumABILanguageRuntime::Initialize();
Greg Claytonb3e77602012-08-23 21:17:11 +0000112#ifndef LLDB_DISABLE_PYTHON
113 OperatingSystemPython::Initialize();
114#endif
115
Greg Claytone996fd32011-03-08 22:40:15 +0000116#if defined (__APPLE__)
Greg Clayton1cb64962011-03-24 04:28:38 +0000117 //----------------------------------------------------------------------
118 // Apple/Darwin hosted plugins
119 //----------------------------------------------------------------------
Eli Friedmane13a8db2010-06-13 19:36:42 +0000120 DynamicLoaderMacOSXDYLD::Initialize();
Greg Clayton944b8282011-08-22 22:30:57 +0000121 DynamicLoaderDarwinKernel::Initialize();
122 OperatingSystemDarwinKernel::Initialize();
Jim Ingham22777012010-09-23 02:01:19 +0000123 AppleObjCRuntimeV2::Initialize();
Jim Ingham2a5e0f02010-11-04 18:30:59 +0000124 AppleObjCRuntimeV1::Initialize();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000125 ObjectContainerUniversalMachO::Initialize();
126 ObjectFileMachO::Initialize();
Jason Molenda382dcfd2012-06-01 01:39:46 +0000127 ProcessKDP::Initialize();
Greg Claytonc3776bf2012-02-09 06:16:32 +0000128 ProcessMachCore::Initialize();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000129 SymbolVendorMacOSX::Initialize();
Greg Claytonded470d2011-03-19 01:12:21 +0000130 PlatformRemoteiOS::Initialize();
Greg Claytonb3a40ba2012-03-20 18:34:04 +0000131 PlatformMacOSX::Initialize();
Greg Clayton722cec22012-02-25 06:56:35 +0000132 PlatformiOSSimulator::Initialize();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000133#endif
Greg Claytone996fd32011-03-08 22:40:15 +0000134#if defined (__linux__)
Greg Clayton1cb64962011-03-24 04:28:38 +0000135 //----------------------------------------------------------------------
136 // Linux hosted plugins
137 //----------------------------------------------------------------------
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000138 ProcessLinux::Initialize();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000139#endif
Johnny Chen8f3d8382011-08-02 20:52:42 +0000140#if defined (__FreeBSD__)
Johnny Chen30213ff2012-01-05 19:17:38 +0000141 ProcessFreeBSD::Initialize();
Johnny Chen8f3d8382011-08-02 20:52:42 +0000142#endif
Greg Clayton1cb64962011-03-24 04:28:38 +0000143 //----------------------------------------------------------------------
144 // Platform agnostic plugins
145 //----------------------------------------------------------------------
146 PlatformRemoteGDBServer::Initialize ();
Daniel Malea97059d42013-01-08 14:55:36 +0000147 ProcessGDBRemote::Initialize();
Greg Claytonfc7117a2011-03-05 01:04:56 +0000148 DynamicLoaderStatic::Initialize();
Greg Clayton1cb64962011-03-24 04:28:38 +0000149
Greg Clayton4272cc72011-02-02 02:24:04 +0000150 // Scan for any system or user LLDB plug-ins
151 PluginManager::Initialize();
Greg Claytonbfe5f3b2011-02-18 01:44:25 +0000152
Caroline Tice20bd37f2011-03-10 22:14:10 +0000153 // The process settings need to know about installed plug-ins, so the Settings must be initialized
154 // AFTER PluginManager::Initialize is called.
155
156 Debugger::SettingsInitialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000157 }
158}
159
160void
161lldb_private::WillTerminate()
162{
163 Host::WillTerminate();
164}
165
166void
167lldb_private::Terminate ()
168{
169 Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
Greg Clayton4272cc72011-02-02 02:24:04 +0000170
171 // Terminate and unload and loaded system or user LLDB plug-ins
172 PluginManager::Terminate();
173
Peter Collingbourne1b27dac2011-05-19 18:32:34 +0000174 ABIMacOSX_i386::Terminate();
175 ABIMacOSX_arm::Terminate();
Peter Collingbournea09bfca2011-05-19 17:34:40 +0000176 ABISysV_x86_64::Terminate();
Sean Callanan95e5c632012-02-17 00:53:45 +0000177 DisassemblerLLVMC::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000178 ObjectContainerBSDArchive::Terminate();
179 ObjectFileELF::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000180 SymbolFileDWARF::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000181 SymbolFileSymtab::Terminate();
Greg Claytonffc922e32011-04-25 21:05:07 +0000182 UnwindAssembly_x86::Terminate();
183 UnwindAssemblyInstEmulation::Terminate();
Caroline Ticead379efc2011-04-05 18:46:00 +0000184 EmulateInstructionARM::Terminate ();
Greg Claytonf754f882011-09-09 20:33:05 +0000185 ObjectFilePECOFF::Terminate ();
Bill Wendlinge50ab402012-04-05 17:38:07 +0000186 DynamicLoaderPOSIXDYLD::Terminate ();
Greg Claytonea5e0cc2012-02-27 19:12:12 +0000187 PlatformFreeBSD::Terminate();
188 PlatformLinux::Terminate();
Andrew Kaylor7b6376b2012-12-14 21:03:37 +0000189 SymbolFileDWARFDebugMap::Terminate();
190 ItaniumABILanguageRuntime::Terminate();
Greg Claytonb3e77602012-08-23 21:17:11 +0000191#ifndef LLDB_DISABLE_PYTHON
192 OperatingSystemPython::Terminate();
193#endif
194
Greg Claytone996fd32011-03-08 22:40:15 +0000195#if defined (__APPLE__)
Eli Friedmane13a8db2010-06-13 19:36:42 +0000196 DynamicLoaderMacOSXDYLD::Terminate();
Greg Clayton944b8282011-08-22 22:30:57 +0000197 DynamicLoaderDarwinKernel::Terminate();
198 OperatingSystemDarwinKernel::Terminate();
Jim Ingham2a5e0f02010-11-04 18:30:59 +0000199 AppleObjCRuntimeV2::Terminate();
200 AppleObjCRuntimeV1::Terminate();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000201 ObjectContainerUniversalMachO::Terminate();
202 ObjectFileMachO::Terminate();
Greg Claytonc3776bf2012-02-09 06:16:32 +0000203 ProcessMachCore::Terminate();
Jason Molenda382dcfd2012-06-01 01:39:46 +0000204 ProcessKDP::Terminate();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000205 SymbolVendorMacOSX::Terminate();
Greg Claytone996fd32011-03-08 22:40:15 +0000206 PlatformMacOSX::Terminate();
Greg Claytonded470d2011-03-19 01:12:21 +0000207 PlatformRemoteiOS::Terminate();
Greg Clayton722cec22012-02-25 06:56:35 +0000208 PlatformiOSSimulator::Terminate();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000209#endif
210
Caroline Tice20bd37f2011-03-10 22:14:10 +0000211 Debugger::SettingsTerminate ();
Greg Clayton99d0faf2010-11-18 23:32:35 +0000212
Greg Claytone996fd32011-03-08 22:40:15 +0000213#if defined (__linux__)
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000214 ProcessLinux::Terminate();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000215#endif
Johnny Chen8f3d8382011-08-02 20:52:42 +0000216
217#if defined (__FreeBSD__)
Johnny Chen30213ff2012-01-05 19:17:38 +0000218 ProcessFreeBSD::Terminate();
Johnny Chen8f3d8382011-08-02 20:52:42 +0000219#endif
Greg Claytonfc7117a2011-03-05 01:04:56 +0000220
Daniel Malea97059d42013-01-08 14:55:36 +0000221 ProcessGDBRemote::Terminate();
Greg Claytonfc7117a2011-03-05 01:04:56 +0000222 DynamicLoaderStatic::Terminate();
Greg Clayton99d0faf2010-11-18 23:32:35 +0000223
224 Log::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000225}
226
Daniel Malea3b92f002013-02-28 16:51:15 +0000227#if defined (__APPLE__)
Sean Callanan3d27e662013-03-07 22:29:06 +0000228extern "C" const unsigned char liblldb_coreVersionString[];
Greg Clayton7170f3f2013-02-28 18:09:18 +0000229#else
230
231#include "clang/Basic/Version.h"
232
233static const char *
234GetLLDBRevision()
235{
236#ifdef LLDB_REVISION
237 return LLDB_REVISION;
238#else
239 return NULL;
240#endif
241}
242
243static const char *
244GetLLDBRepository()
245{
246#ifdef LLDB_REPOSITORY
247 return LLDB_REPOSITORY;
248#else
249 return NULL;
250#endif
251}
252
Daniel Malea3b92f002013-02-28 16:51:15 +0000253#endif
254
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000255const char *
256lldb_private::GetVersion ()
257{
Daniel Malea3b92f002013-02-28 16:51:15 +0000258#if defined (__APPLE__)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000259 static char g_version_string[32];
260 if (g_version_string[0] == '\0')
Sean Callanan3d27e662013-03-07 22:29:06 +0000261 {
262 const char *version_string = ::strstr ((const char *)liblldb_coreVersionString, "PROJECT:");
263
264 if (version_string)
265 version_string += sizeof("PROJECT:") - 1;
266 else
267 version_string = "unknown";
268
269 const char *newline_loc = strchr(version_string, '\n');
270
271 size_t version_len = sizeof(g_version_string);
272
273 if (newline_loc && (newline_loc - version_string < version_len))
274 version_len = newline_loc - version_string;
275
276 ::strncpy(g_version_string, version_string, version_len);
277 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000278
279 return g_version_string;
Daniel Malea3b92f002013-02-28 16:51:15 +0000280#else
281 // On Linux/FreeBSD/Windows, report a version number in the same style as the clang tool.
Greg Clayton7170f3f2013-02-28 18:09:18 +0000282 static std::string g_version_str;
283 if (g_version_str.empty())
284 {
285 g_version_str += "lldb version ";
286 g_version_str += CLANG_VERSION_STRING;
287 const char * lldb_repo = GetLLDBRepository();
288 if (lldb_repo)
289 {
290 g_version_str += " (";
291 g_version_str += lldb_repo;
292 }
Daniel Malea3b92f002013-02-28 16:51:15 +0000293
Greg Clayton7170f3f2013-02-28 18:09:18 +0000294 const char *lldb_rev = GetLLDBRevision();
295 if (lldb_rev)
296 {
297 g_version_str += " revision ";
298 g_version_str += lldb_rev;
299 }
300 std::string clang_rev (clang::getClangRevision());
301 if (clang_rev.length() > 0)
302 {
303 g_version_str += " clang revision ";
304 g_version_str += clang_rev;
305 }
306 std::string llvm_rev (clang::getLLVMRevision());
307 if (llvm_rev.length() > 0)
308 {
309 g_version_str += " llvm revision ";
310 g_version_str += llvm_rev;
311 }
Daniel Malea3b92f002013-02-28 16:51:15 +0000312
Greg Clayton7170f3f2013-02-28 18:09:18 +0000313 if (lldb_repo)
314 g_version_str += ")";
315 }
316 return g_version_str.c_str();
Daniel Malea3b92f002013-02-28 16:51:15 +0000317#endif
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000318}
319
Greg Clayton2cad65a2010-09-03 17:10:42 +0000320const char *
Greg Claytone0d378b2011-03-24 21:19:54 +0000321lldb_private::GetVoteAsCString (Vote vote)
Greg Clayton2cad65a2010-09-03 17:10:42 +0000322{
Greg Clayton1346f7e2010-09-03 22:45:01 +0000323 switch (vote)
324 {
325 case eVoteNo: return "no";
326 case eVoteNoOpinion: return "no opinion";
327 case eVoteYes: return "yes";
Greg Clayton1346f7e2010-09-03 22:45:01 +0000328 }
Greg Clayton2cad65a2010-09-03 17:10:42 +0000329 return "invalid";
330}
331
Greg Clayton89411422010-10-08 00:21:05 +0000332
333const char *
Greg Claytone0d378b2011-03-24 21:19:54 +0000334lldb_private::GetSectionTypeAsCString (SectionType sect_type)
Greg Clayton89411422010-10-08 00:21:05 +0000335{
336 switch (sect_type)
337 {
338 case eSectionTypeInvalid: return "invalid";
339 case eSectionTypeCode: return "code";
340 case eSectionTypeContainer: return "container";
341 case eSectionTypeData: return "data";
342 case eSectionTypeDataCString: return "data-cstr";
343 case eSectionTypeDataCStringPointers: return "data-cstr-ptr";
344 case eSectionTypeDataSymbolAddress: return "data-symbol-addr";
345 case eSectionTypeData4: return "data-4-byte";
346 case eSectionTypeData8: return "data-8-byte";
347 case eSectionTypeData16: return "data-16-byte";
348 case eSectionTypeDataPointers: return "data-ptrs";
349 case eSectionTypeDebug: return "debug";
350 case eSectionTypeZeroFill: return "zero-fill";
351 case eSectionTypeDataObjCMessageRefs: return "objc-message-refs";
352 case eSectionTypeDataObjCCFStrings: return "objc-cfstrings";
353 case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev";
354 case eSectionTypeDWARFDebugAranges: return "dwarf-aranges";
355 case eSectionTypeDWARFDebugFrame: return "dwarf-frame";
356 case eSectionTypeDWARFDebugInfo: return "dwarf-info";
357 case eSectionTypeDWARFDebugLine: return "dwarf-line";
358 case eSectionTypeDWARFDebugLoc: return "dwarf-loc";
359 case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo";
360 case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames";
361 case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes";
362 case eSectionTypeDWARFDebugRanges: return "dwarf-ranges";
363 case eSectionTypeDWARFDebugStr: return "dwarf-str";
Greg Clayton17674402011-09-28 17:06:40 +0000364 case eSectionTypeDWARFAppleNames: return "apple-names";
365 case eSectionTypeDWARFAppleTypes: return "apple-types";
Greg Clayton7f995132011-10-04 22:41:51 +0000366 case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces";
Greg Clayton5009f9d2011-10-27 17:55:14 +0000367 case eSectionTypeDWARFAppleObjC: return "apple-objc";
Greg Clayton89411422010-10-08 00:21:05 +0000368 case eSectionTypeEHFrame: return "eh-frame";
369 case eSectionTypeOther: return "regular";
370 }
371 return "unknown";
372
373}
374
Greg Claytone996fd32011-03-08 22:40:15 +0000375bool
376lldb_private::NameMatches (const char *name,
Greg Claytone0d378b2011-03-24 21:19:54 +0000377 NameMatchType match_type,
Greg Claytone996fd32011-03-08 22:40:15 +0000378 const char *match)
379{
380 if (match_type == eNameMatchIgnore)
381 return true;
382
383 if (name == match)
384 return true;
385
386 if (name && match)
387 {
388 llvm::StringRef name_sref(name);
389 llvm::StringRef match_sref(match);
390 switch (match_type)
391 {
392 case eNameMatchIgnore:
393 return true;
394 case eNameMatchEquals: return name_sref == match_sref;
395 case eNameMatchContains: return name_sref.find (match_sref) != llvm::StringRef::npos;
396 case eNameMatchStartsWith: return name_sref.startswith (match_sref);
397 case eNameMatchEndsWith: return name_sref.endswith (match_sref);
398 case eNameMatchRegularExpression:
399 {
400 RegularExpression regex (match);
401 return regex.Execute (name);
402 }
403 break;
Greg Claytone996fd32011-03-08 22:40:15 +0000404 }
405 }
406 return false;
407}