blob: 7bc2c4e04c5798a25f48e3a266c44c8c5b10562f [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 Malea3b92f002013-02-28 16:51:15 +000010#include "clang/Basic/Version.h"
11
Daniel Malea93a64302012-12-05 00:20:57 +000012#include "lldb/lldb-python.h"
13
Chris Lattner30fdc8d2010-06-08 16:52:24 +000014#include "lldb/lldb-private.h"
15#include "lldb/lldb-private-log.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000016#include "lldb/Core/ArchSpec.h"
Stephen Wilson28c16d92011-03-13 00:00:32 +000017#include "lldb/Core/Debugger.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018#include "lldb/Core/Log.h"
Greg Clayton4272cc72011-02-02 02:24:04 +000019#include "lldb/Core/PluginManager.h"
Greg Claytone996fd32011-03-08 22:40:15 +000020#include "lldb/Core/RegularExpression.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021#include "lldb/Core/Timer.h"
22#include "lldb/Host/Host.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000023#include "lldb/Host/Mutex.h"
Greg Clayton3c310a12010-12-16 21:36:30 +000024#include "lldb/Target/Target.h"
25#include "lldb/Target/Thread.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000026
Greg Claytone996fd32011-03-08 22:40:15 +000027#include "llvm/ADT/StringRef.h"
Daniel Malea3b92f002013-02-28 16:51:15 +000028#include "llvm/Support/raw_ostream.h"
Greg Claytone996fd32011-03-08 22:40:15 +000029
Peter Collingbourne1b27dac2011-05-19 18:32:34 +000030#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
31#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
Peter Collingbournea09bfca2011-05-19 17:34:40 +000032#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
Sean Callanan95e5c632012-02-17 00:53:45 +000033#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
Caroline Ticead379efc2011-04-05 18:46:00 +000034#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000035#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
36#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
37#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
38#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
39#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
40#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
Greg Clayton078daac2011-04-25 21:07:40 +000041#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
Greg Claytonffc922e32011-04-25 21:05:07 +000042#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
Greg Claytonf754f882011-09-09 20:33:05 +000043#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
Greg Claytond10a0382012-02-27 19:00:34 +000044#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
Greg Claytonea5e0cc2012-02-27 19:12:12 +000045#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
46#include "Plugins/Platform/Linux/PlatformLinux.h"
Andrew Kaylor7b6376b2012-12-14 21:03:37 +000047#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
Greg Claytonb3e77602012-08-23 21:17:11 +000048#ifndef LLDB_DISABLE_PYTHON
49#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
50#endif
Greg Claytone996fd32011-03-08 22:40:15 +000051#if defined (__APPLE__)
Eli Friedmane13a8db2010-06-13 19:36:42 +000052#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
Greg Clayton944b8282011-08-22 22:30:57 +000053#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
54#include "Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h"
Jim Ingham2a5e0f02010-11-04 18:30:59 +000055#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
56#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000057#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
58#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
Greg Clayton3a29bdb2011-07-17 20:36:25 +000059#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
Greg Claytone996fd32011-03-08 22:40:15 +000060#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
Greg Claytonded470d2011-03-19 01:12:21 +000061#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
Greg Clayton722cec22012-02-25 06:56:35 +000062#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
Eli Friedmane13a8db2010-06-13 19:36:42 +000063#endif
Chris Lattner30fdc8d2010-06-08 16:52:24 +000064
Greg Claytonc3776bf2012-02-09 06:16:32 +000065#include "Plugins/Process/mach-core/ProcessMachCore.h"
66
Greg Claytone996fd32011-03-08 22:40:15 +000067#if defined (__linux__)
Greg Claytone996fd32011-03-08 22:40:15 +000068#include "Plugins/Process/Linux/ProcessLinux.h"
Stephen Wilsone6f9f662010-07-24 02:19:04 +000069#endif
70
Johnny Chen8f3d8382011-08-02 20:52:42 +000071#if defined (__FreeBSD__)
Johnny Chen30213ff2012-01-05 19:17:38 +000072#include "Plugins/Process/POSIX/ProcessPOSIX.h"
73#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
Johnny Chen8f3d8382011-08-02 20:52:42 +000074#endif
75
Greg Clayton1cb64962011-03-24 04:28:38 +000076#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
Daniel Malea97059d42013-01-08 14:55:36 +000077#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
Greg Claytonfc7117a2011-03-05 01:04:56 +000078#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
79
Greg Claytonce6d19a2010-12-16 21:33:41 +000080using namespace lldb;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000081using namespace lldb_private;
82
Daniel Malea3b92f002013-02-28 16:51:15 +000083namespace {
84
85std::string getLLDBRevision() {
86#ifdef LLDB_REVISION
87 return LLDB_REVISION;
88#else
89 return "";
90#endif
91}
92
93std::string getLLDBRepository() {
94#ifdef LLDB_REPOSITORY
95 return LLDB_REPOSITORY;
96#else
97 return "";
98#endif
99}
100
101}
102
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000103void
104lldb_private::Initialize ()
105{
106 // Make sure we inialize only once
Caroline Tice2f88aad2011-01-14 00:29:16 +0000107 static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000108 static bool g_inited = false;
109
110 Mutex::Locker locker(g_inited_mutex);
111 if (!g_inited)
112 {
113 g_inited = true;
Greg Clayton99d0faf2010-11-18 23:32:35 +0000114 Log::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000115 Timer::Initialize ();
116 Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
Greg Clayton99d0faf2010-11-18 23:32:35 +0000117
Peter Collingbourne1b27dac2011-05-19 18:32:34 +0000118 ABIMacOSX_i386::Initialize();
119 ABIMacOSX_arm::Initialize();
Peter Collingbournea09bfca2011-05-19 17:34:40 +0000120 ABISysV_x86_64::Initialize();
Sean Callanan95e5c632012-02-17 00:53:45 +0000121 DisassemblerLLVMC::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000122 ObjectContainerBSDArchive::Initialize();
123 ObjectFileELF::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000124 SymbolFileDWARF::Initialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000125 SymbolFileSymtab::Initialize();
Greg Claytonffc922e32011-04-25 21:05:07 +0000126 UnwindAssemblyInstEmulation::Initialize();
Greg Clayton2ed751b2011-04-26 04:39:08 +0000127 UnwindAssembly_x86::Initialize();
Caroline Ticead379efc2011-04-05 18:46:00 +0000128 EmulateInstructionARM::Initialize ();
Greg Claytonf754f882011-09-09 20:33:05 +0000129 ObjectFilePECOFF::Initialize ();
Bill Wendlinge50ab402012-04-05 17:38:07 +0000130 DynamicLoaderPOSIXDYLD::Initialize ();
Greg Claytonea5e0cc2012-02-27 19:12:12 +0000131 PlatformFreeBSD::Initialize();
132 PlatformLinux::Initialize();
Andrew Kaylor7b6376b2012-12-14 21:03:37 +0000133 SymbolFileDWARFDebugMap::Initialize();
134 ItaniumABILanguageRuntime::Initialize();
Greg Claytonb3e77602012-08-23 21:17:11 +0000135#ifndef LLDB_DISABLE_PYTHON
136 OperatingSystemPython::Initialize();
137#endif
138
Greg Claytone996fd32011-03-08 22:40:15 +0000139#if defined (__APPLE__)
Greg Clayton1cb64962011-03-24 04:28:38 +0000140 //----------------------------------------------------------------------
141 // Apple/Darwin hosted plugins
142 //----------------------------------------------------------------------
Eli Friedmane13a8db2010-06-13 19:36:42 +0000143 DynamicLoaderMacOSXDYLD::Initialize();
Greg Clayton944b8282011-08-22 22:30:57 +0000144 DynamicLoaderDarwinKernel::Initialize();
145 OperatingSystemDarwinKernel::Initialize();
Jim Ingham22777012010-09-23 02:01:19 +0000146 AppleObjCRuntimeV2::Initialize();
Jim Ingham2a5e0f02010-11-04 18:30:59 +0000147 AppleObjCRuntimeV1::Initialize();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000148 ObjectContainerUniversalMachO::Initialize();
149 ObjectFileMachO::Initialize();
Jason Molenda382dcfd2012-06-01 01:39:46 +0000150 ProcessKDP::Initialize();
Greg Claytonc3776bf2012-02-09 06:16:32 +0000151 ProcessMachCore::Initialize();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000152 SymbolVendorMacOSX::Initialize();
Greg Claytonded470d2011-03-19 01:12:21 +0000153 PlatformRemoteiOS::Initialize();
Greg Claytonb3a40ba2012-03-20 18:34:04 +0000154 PlatformMacOSX::Initialize();
Greg Clayton722cec22012-02-25 06:56:35 +0000155 PlatformiOSSimulator::Initialize();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000156#endif
Greg Claytone996fd32011-03-08 22:40:15 +0000157#if defined (__linux__)
Greg Clayton1cb64962011-03-24 04:28:38 +0000158 //----------------------------------------------------------------------
159 // Linux hosted plugins
160 //----------------------------------------------------------------------
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000161 ProcessLinux::Initialize();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000162#endif
Johnny Chen8f3d8382011-08-02 20:52:42 +0000163#if defined (__FreeBSD__)
Johnny Chen30213ff2012-01-05 19:17:38 +0000164 ProcessFreeBSD::Initialize();
Johnny Chen8f3d8382011-08-02 20:52:42 +0000165#endif
Greg Clayton1cb64962011-03-24 04:28:38 +0000166 //----------------------------------------------------------------------
167 // Platform agnostic plugins
168 //----------------------------------------------------------------------
169 PlatformRemoteGDBServer::Initialize ();
Daniel Malea97059d42013-01-08 14:55:36 +0000170 ProcessGDBRemote::Initialize();
Greg Claytonfc7117a2011-03-05 01:04:56 +0000171 DynamicLoaderStatic::Initialize();
Greg Clayton1cb64962011-03-24 04:28:38 +0000172
Greg Clayton4272cc72011-02-02 02:24:04 +0000173 // Scan for any system or user LLDB plug-ins
174 PluginManager::Initialize();
Greg Claytonbfe5f3b2011-02-18 01:44:25 +0000175
Caroline Tice20bd37f2011-03-10 22:14:10 +0000176 // The process settings need to know about installed plug-ins, so the Settings must be initialized
177 // AFTER PluginManager::Initialize is called.
178
179 Debugger::SettingsInitialize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000180 }
181}
182
183void
184lldb_private::WillTerminate()
185{
186 Host::WillTerminate();
187}
188
189void
190lldb_private::Terminate ()
191{
192 Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
Greg Clayton4272cc72011-02-02 02:24:04 +0000193
194 // Terminate and unload and loaded system or user LLDB plug-ins
195 PluginManager::Terminate();
196
Peter Collingbourne1b27dac2011-05-19 18:32:34 +0000197 ABIMacOSX_i386::Terminate();
198 ABIMacOSX_arm::Terminate();
Peter Collingbournea09bfca2011-05-19 17:34:40 +0000199 ABISysV_x86_64::Terminate();
Sean Callanan95e5c632012-02-17 00:53:45 +0000200 DisassemblerLLVMC::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000201 ObjectContainerBSDArchive::Terminate();
202 ObjectFileELF::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000203 SymbolFileDWARF::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000204 SymbolFileSymtab::Terminate();
Greg Claytonffc922e32011-04-25 21:05:07 +0000205 UnwindAssembly_x86::Terminate();
206 UnwindAssemblyInstEmulation::Terminate();
Caroline Ticead379efc2011-04-05 18:46:00 +0000207 EmulateInstructionARM::Terminate ();
Greg Claytonf754f882011-09-09 20:33:05 +0000208 ObjectFilePECOFF::Terminate ();
Bill Wendlinge50ab402012-04-05 17:38:07 +0000209 DynamicLoaderPOSIXDYLD::Terminate ();
Greg Claytonea5e0cc2012-02-27 19:12:12 +0000210 PlatformFreeBSD::Terminate();
211 PlatformLinux::Terminate();
Andrew Kaylor7b6376b2012-12-14 21:03:37 +0000212 SymbolFileDWARFDebugMap::Terminate();
213 ItaniumABILanguageRuntime::Terminate();
Greg Claytonb3e77602012-08-23 21:17:11 +0000214#ifndef LLDB_DISABLE_PYTHON
215 OperatingSystemPython::Terminate();
216#endif
217
Greg Claytone996fd32011-03-08 22:40:15 +0000218#if defined (__APPLE__)
Eli Friedmane13a8db2010-06-13 19:36:42 +0000219 DynamicLoaderMacOSXDYLD::Terminate();
Greg Clayton944b8282011-08-22 22:30:57 +0000220 DynamicLoaderDarwinKernel::Terminate();
221 OperatingSystemDarwinKernel::Terminate();
Jim Ingham2a5e0f02010-11-04 18:30:59 +0000222 AppleObjCRuntimeV2::Terminate();
223 AppleObjCRuntimeV1::Terminate();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000224 ObjectContainerUniversalMachO::Terminate();
225 ObjectFileMachO::Terminate();
Greg Claytonc3776bf2012-02-09 06:16:32 +0000226 ProcessMachCore::Terminate();
Jason Molenda382dcfd2012-06-01 01:39:46 +0000227 ProcessKDP::Terminate();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000228 SymbolVendorMacOSX::Terminate();
Greg Claytone996fd32011-03-08 22:40:15 +0000229 PlatformMacOSX::Terminate();
Greg Claytonded470d2011-03-19 01:12:21 +0000230 PlatformRemoteiOS::Terminate();
Greg Clayton722cec22012-02-25 06:56:35 +0000231 PlatformiOSSimulator::Terminate();
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000232#endif
233
Caroline Tice20bd37f2011-03-10 22:14:10 +0000234 Debugger::SettingsTerminate ();
Greg Clayton99d0faf2010-11-18 23:32:35 +0000235
Greg Claytone996fd32011-03-08 22:40:15 +0000236#if defined (__linux__)
Stephen Wilsone6f9f662010-07-24 02:19:04 +0000237 ProcessLinux::Terminate();
Eli Friedmane13a8db2010-06-13 19:36:42 +0000238#endif
Johnny Chen8f3d8382011-08-02 20:52:42 +0000239
240#if defined (__FreeBSD__)
Johnny Chen30213ff2012-01-05 19:17:38 +0000241 ProcessFreeBSD::Terminate();
Johnny Chen8f3d8382011-08-02 20:52:42 +0000242#endif
Greg Claytonfc7117a2011-03-05 01:04:56 +0000243
Daniel Malea97059d42013-01-08 14:55:36 +0000244 ProcessGDBRemote::Terminate();
Greg Claytonfc7117a2011-03-05 01:04:56 +0000245 DynamicLoaderStatic::Terminate();
Greg Clayton99d0faf2010-11-18 23:32:35 +0000246
247 Log::Terminate();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000248}
249
Daniel Malea3b92f002013-02-28 16:51:15 +0000250
251#if defined (__APPLE__)
Greg Claytonfc36f7912011-03-22 01:14:58 +0000252extern "C" const double liblldb_coreVersionNumber;
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')
Greg Claytonfc36f7912011-03-22 01:14:58 +0000261 ::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", liblldb_coreVersionNumber);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000262
263 return g_version_string;
Daniel Malea3b92f002013-02-28 16:51:15 +0000264#else
265 // On Linux/FreeBSD/Windows, report a version number in the same style as the clang tool.
266 static std::string buf;
267 llvm::raw_string_ostream OS(buf);
268 OS << "lldb version " CLANG_VERSION_STRING " ";
269
270 std::string lldb_repo = getLLDBRepository();
271 if (lldb_repo.length() > 0)
272 OS << "(" << lldb_repo;
273
274 std::string lldb_rev = getLLDBRevision();
275 if (lldb_rev.length() > 0)
276 OS << " revision " << lldb_rev;
277
278 std::string clang_rev = clang::getClangRevision();
279 if (clang_rev.length() > 0)
280 OS << " clang revision " << clang_rev;
281
282 std::string llvm_rev = clang::getLLVMRevision();
283 if (llvm_rev.length() > 0)
284 OS << " llvm revision " << llvm_rev;
285
286 if (lldb_repo.length() > 0)
287 OS << ")";
288
289 return OS.str().c_str();
290#endif
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000291}
292
Greg Clayton2cad65a2010-09-03 17:10:42 +0000293const char *
Greg Claytone0d378b2011-03-24 21:19:54 +0000294lldb_private::GetVoteAsCString (Vote vote)
Greg Clayton2cad65a2010-09-03 17:10:42 +0000295{
Greg Clayton1346f7e2010-09-03 22:45:01 +0000296 switch (vote)
297 {
298 case eVoteNo: return "no";
299 case eVoteNoOpinion: return "no opinion";
300 case eVoteYes: return "yes";
Greg Clayton1346f7e2010-09-03 22:45:01 +0000301 }
Greg Clayton2cad65a2010-09-03 17:10:42 +0000302 return "invalid";
303}
304
Greg Clayton89411422010-10-08 00:21:05 +0000305
306const char *
Greg Claytone0d378b2011-03-24 21:19:54 +0000307lldb_private::GetSectionTypeAsCString (SectionType sect_type)
Greg Clayton89411422010-10-08 00:21:05 +0000308{
309 switch (sect_type)
310 {
311 case eSectionTypeInvalid: return "invalid";
312 case eSectionTypeCode: return "code";
313 case eSectionTypeContainer: return "container";
314 case eSectionTypeData: return "data";
315 case eSectionTypeDataCString: return "data-cstr";
316 case eSectionTypeDataCStringPointers: return "data-cstr-ptr";
317 case eSectionTypeDataSymbolAddress: return "data-symbol-addr";
318 case eSectionTypeData4: return "data-4-byte";
319 case eSectionTypeData8: return "data-8-byte";
320 case eSectionTypeData16: return "data-16-byte";
321 case eSectionTypeDataPointers: return "data-ptrs";
322 case eSectionTypeDebug: return "debug";
323 case eSectionTypeZeroFill: return "zero-fill";
324 case eSectionTypeDataObjCMessageRefs: return "objc-message-refs";
325 case eSectionTypeDataObjCCFStrings: return "objc-cfstrings";
326 case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev";
327 case eSectionTypeDWARFDebugAranges: return "dwarf-aranges";
328 case eSectionTypeDWARFDebugFrame: return "dwarf-frame";
329 case eSectionTypeDWARFDebugInfo: return "dwarf-info";
330 case eSectionTypeDWARFDebugLine: return "dwarf-line";
331 case eSectionTypeDWARFDebugLoc: return "dwarf-loc";
332 case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo";
333 case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames";
334 case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes";
335 case eSectionTypeDWARFDebugRanges: return "dwarf-ranges";
336 case eSectionTypeDWARFDebugStr: return "dwarf-str";
Greg Clayton17674402011-09-28 17:06:40 +0000337 case eSectionTypeDWARFAppleNames: return "apple-names";
338 case eSectionTypeDWARFAppleTypes: return "apple-types";
Greg Clayton7f995132011-10-04 22:41:51 +0000339 case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces";
Greg Clayton5009f9d2011-10-27 17:55:14 +0000340 case eSectionTypeDWARFAppleObjC: return "apple-objc";
Greg Clayton89411422010-10-08 00:21:05 +0000341 case eSectionTypeEHFrame: return "eh-frame";
342 case eSectionTypeOther: return "regular";
343 }
344 return "unknown";
345
346}
347
Greg Claytone996fd32011-03-08 22:40:15 +0000348bool
349lldb_private::NameMatches (const char *name,
Greg Claytone0d378b2011-03-24 21:19:54 +0000350 NameMatchType match_type,
Greg Claytone996fd32011-03-08 22:40:15 +0000351 const char *match)
352{
353 if (match_type == eNameMatchIgnore)
354 return true;
355
356 if (name == match)
357 return true;
358
359 if (name && match)
360 {
361 llvm::StringRef name_sref(name);
362 llvm::StringRef match_sref(match);
363 switch (match_type)
364 {
365 case eNameMatchIgnore:
366 return true;
367 case eNameMatchEquals: return name_sref == match_sref;
368 case eNameMatchContains: return name_sref.find (match_sref) != llvm::StringRef::npos;
369 case eNameMatchStartsWith: return name_sref.startswith (match_sref);
370 case eNameMatchEndsWith: return name_sref.endswith (match_sref);
371 case eNameMatchRegularExpression:
372 {
373 RegularExpression regex (match);
374 return regex.Execute (name);
375 }
376 break;
Greg Claytone996fd32011-03-08 22:40:15 +0000377 }
378 }
379 return false;
380}