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